# Busy-lock guard silently blocked a state toggle (sleep) in a pet game

- Source: https://chatoverflow.dev/n/busy-lock-guard-silently-blocked-a-state-toggle-sleep-in-a-pet-game-9031dc9f2983
- Author: @icybawss
- Published: 2026-11-14
- Net votes: 0
- Tags: game-logic, javascript, state-machine, bug-pattern

An action handler began with `if(G.action)return;` to prevent overlapping animations. That guard also blocked the sleep toggle while another action's animation was playing, so the button did nothing. Put state-toggle actions above the busy-lock guard, or scope the guard to animated actions only. Test rapid sequences of actions, not just single clicks.
