fix(api): end every Connection of a Room when it is evicted #548

Merged
root merged 1 commit from fix/435-evict-ends-spectators into main 2026-10-15 23:54:55 +00:00
root commented 2026-10-15 22:44:13 +00:00 (Migrated from gitlab.core-project.space)

Summary

Evicting a Room now ends every Connection it still holds, the way vacating a Seat already ends its other tabs. Watching does not keep a Room alive: ADR 0015 already decided that Spectators never extend its life, so the eviction rule is unchanged.

 sweep
   for each Room idle past the TTL
     delete it from the map
+    endConnections(room)      # each Seat tab and each Spectator: end()

On the front, an ended stream reconnects, the server refuses the code as ROOM_NOT_FOUND, and useRoomChanges latches the Room closed, which room-closed.test.tsx already covers.

Evidence

apps/api/src/room/room-changes.test.ts:

it "ends a Spectator's stream when the Room is evicted under it"
  seated Room, a Spectator's stream waiting on next()
  advance the TTL; a snapshot call sweeps it (room-not-found)
  expect waiting to resolve { done: true }
  • Before: times out after 10 s; the Spectator's next() never resolves.
    After: passes; the five gate commands are green locally.

Merge Danger

Door: two-way

Blast Radius: small

Only Rooms already being evicted are touched; their Spectators now see the closed-Room modal instead of a frozen board.

Closes #435

## Summary Evicting a Room now ends every Connection it still holds, the way vacating a Seat already ends its other tabs. Watching does not keep a Room alive: ADR 0015 already decided that Spectators never extend its life, so the eviction rule is unchanged. ```diff sweep for each Room idle past the TTL delete it from the map + endConnections(room) # each Seat tab and each Spectator: end() ``` On the front, an ended stream reconnects, the server refuses the code as `ROOM_NOT_FOUND`, and `useRoomChanges` latches the Room closed, which `room-closed.test.tsx` already covers. ## Evidence `apps/api/src/room/room-changes.test.ts`: ```text it "ends a Spectator's stream when the Room is evicted under it" seated Room, a Spectator's stream waiting on next() advance the TTL; a snapshot call sweeps it (room-not-found) expect waiting to resolve { done: true } ``` - **Before:** times out after 10 s; the Spectator's `next()` never resolves. **After:** passes; the five gate commands are green locally. ## Merge Danger **Door:** two-way **Blast Radius:** small Only Rooms already being evicted are touched; their Spectators now see the closed-Room modal instead of a frozen board. Closes #435
project_1_bot_a8dd9262857d850eef8dca5206e61de5 commented 2026-10-15 23:12:51 +00:00 (Migrated from gitlab.core-project.space)

Screenshots

Before is production, after is this merge request's review app at c842db7.

Desktop

Page Before After
Home
Local game
Room

Mobile

Page Before After
Home
Local game
Room
<!-- chess-screenshots --> ### Screenshots Before is production, after is this merge request's review app at c842db7. #### Desktop | Page | Before | After | | --- | --- | --- | | Home | <img src="https://gitlab.core-project.space/amaurycoudr/chess-project/-/jobs/1769/artifacts/raw/review-screenshots/before/home-desktop.png" width="400"> | <img src="https://gitlab.core-project.space/amaurycoudr/chess-project/-/jobs/1769/artifacts/raw/review-screenshots/after/home-desktop.png" width="400"> | | Local game | <img src="https://gitlab.core-project.space/amaurycoudr/chess-project/-/jobs/1769/artifacts/raw/review-screenshots/before/local-desktop.png" width="400"> | <img src="https://gitlab.core-project.space/amaurycoudr/chess-project/-/jobs/1769/artifacts/raw/review-screenshots/after/local-desktop.png" width="400"> | | Room | <img src="https://gitlab.core-project.space/amaurycoudr/chess-project/-/jobs/1769/artifacts/raw/review-screenshots/before/room-desktop.png" width="400"> | <img src="https://gitlab.core-project.space/amaurycoudr/chess-project/-/jobs/1769/artifacts/raw/review-screenshots/after/room-desktop.png" width="400"> | #### Mobile | Page | Before | After | | --- | --- | --- | | Home | <img src="https://gitlab.core-project.space/amaurycoudr/chess-project/-/jobs/1769/artifacts/raw/review-screenshots/before/home-mobile.png" width="200"> | <img src="https://gitlab.core-project.space/amaurycoudr/chess-project/-/jobs/1769/artifacts/raw/review-screenshots/after/home-mobile.png" width="200"> | | Local game | <img src="https://gitlab.core-project.space/amaurycoudr/chess-project/-/jobs/1769/artifacts/raw/review-screenshots/before/local-mobile.png" width="200"> | <img src="https://gitlab.core-project.space/amaurycoudr/chess-project/-/jobs/1769/artifacts/raw/review-screenshots/after/local-mobile.png" width="200"> | | Room | <img src="https://gitlab.core-project.space/amaurycoudr/chess-project/-/jobs/1769/artifacts/raw/review-screenshots/before/room-mobile.png" width="200"> | <img src="https://gitlab.core-project.space/amaurycoudr/chess-project/-/jobs/1769/artifacts/raw/review-screenshots/after/room-mobile.png" width="200"> |
root commented 2026-10-15 23:47:45 +00:00 (Migrated from gitlab.core-project.space)

added 21 commits

  • 8795b3d3...10f7ed9c - 20 commits from branch main
  • c842db7f - fix(api): end every Connection of a Room when it is evicted

Compare with previous version

added 21 commits <ul><li>8795b3d3...10f7ed9c - 20 commits from branch <code>main</code></li><li>c842db7f - fix(api): end every Connection of a Room when it is evicted</li></ul> [Compare with previous version](/amaurycoudr/chess-project/-/merge_requests/48/diffs?diff_id=306&start_sha=8795b3d3c8bf1ad3afde802a1d160a5ba0981d8f)
root (Migrated from gitlab.core-project.space) merged commit into main 2026-10-15 23:54:55 +00:00
Sign in to join this conversation.
No description provided.