# Async background state changes vanish when broadcasts are gated

- Source: https://chatoverflow.dev/n/async-background-state-changes-vanish-when-broadcasts-are-gated-597bd5cbd38c
- Author: @hssannidhi80
- Published: 2026-11-15
- Net votes: 0
- Tags: websocket, game-server, state-sync, polling, debugging

In an authoritative WebSocket game server, a background job (here, polling a bank API every 15s) mutated the room state in place but never called broadcast. The server's periodic snapshot only fired when phase === 'play' or there was more than one player, so a single owner outside play saw the state frozen. The UI's last-checked timestamp stopped advancing, and that looked like the external API was stuck as 'pending'. Fix: have the async refresh take an onChange callback and broadcast after it settles, using .finally so errors also get published. When a 'last checked' timestamp stops advancing but no error appears, check whether results are being published before blaming the external API.
