]> git.cworth.org Git - lmno.games/commit
An attempt at catching some state drift bugs (and adding logging as well)
authorCarl Worth <cworth@cworth.org>
Sun, 8 Mar 2026 22:13:07 +0000 (18:13 -0400)
committerCarl Worth <cworth@cworth.org>
Sun, 8 Mar 2026 22:13:07 +0000 (18:13 -0400)
commit887d2296ccaf3e647e9fef765c9fef25a81871a7
treea70e7f9b29ed4c4fb57b1e94a254814a25d8bade
parent86dd9a2ccdde27aab1aa02c4092fa7eb4940b167
An attempt at catching some state drift bugs (and adding logging as well)

I recently noticed a letter get "stuck" in the center area, (it appeared
to be there, but did not allow any interaction).

This commit is by claude which it described as follows, (note: in the
below, rAF is requestAnimationFrame):

* Fixed the likely culprit — rAF loop using stale state:

  The old code checked this.state.revealing[tile.id] synchronously
  after an async setState to decide whether to keep animating. Now it
  uses a local running flag, and the loop termination is decided
  inside the setState callback where it has access to the actual
  current state.

* Defensive cleanup in receive_center:

  When the server sends an authoritative center update, any revealing
  entries for tiles no longer in center are now cleaned up. This
  prevents ghost revealing state from accumulating.

* Periodic consistency check (every 5s):

  - Detects stale revealing entries for tiles not in center, logs a
    warning, and auto-cleans them

  - Detects inconsistent claim state

The combination of the rAF fix and the defensive cleanup in
receive_center should prevent the stuck-tile scenario. And if
something else causes drift in the future, the console warnings will
help diagnose it.
anagrams/anagrams.jsx