fix(front): retry a call signed out once the refresh is refused #558
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
spec
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
amaurycoudr/chess-project!558
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/stale-session-public-read"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
A browser left with a stale
__Host-accesscookie opened/games/abc123on the router's error screen ("Something went wrong!") instead of Game not found. The API was right: it refuses a token it cannot accept, even on an optional read, so the front refreshes (ADR 0030). The refused refresh clears both cookies, but the client rethrew the firstUNAUTHORIZEDinstead of retrying. The malformed id was a red herring: whichever call ran first after the cookie went stale failed, and every later one read anonymously. That is why the UUID link looked fine.ADR 0030 already says "calls the refresh procedure once per tab at a time, then retries the call once". The client now does that whatever the refresh answers.
use-room-changeshad its own copy of this ("A refused refresh has cleared the Session's cookies, so one more stream opens signed out"). With the client retrying, that copy doubled the reopen (5 calls instead of 3), so it is removed.Evidence
GET /rpc/games/abc123 401→POST /rpc/session/refresh 401→ error screen. This happened in 4 of 4 runs on the dev stack, using a Playwright script that seeds a stale access cookie.After:
GET /rpc/games/abc123 401→POST /rpc/session/refresh 401→GET /rpc/games/abc123 404→ Game not found, also in 4 of 4 runs.game-page-route.test.tsx: "mounts the not-found page for a browser left with a Session the refresh cannot save". It fails onmainand passes here. The games fake server gains astaleSessionoption for it.session-refresh.test.tsx: a public read answers anonymously after a refused refresh, andaccount.exportis still refusedUNAUTHORIZED.session-refreshtheaccount.mecount goes from 1 to 2. Inroute-guardsandsession-refresh,game.listnow resolves instead of rejecting. Both still check that the Player is shown signed out.Merge Danger
Door: two-way
Blast Radius: auth
Question for the owner: every call is now retried once after a refused refresh, writes included. A write that accepts a Guest, such as creating a Room, now succeeds as the browser's Guest. Before, it failed with
UNAUTHORIZEDwhen the Player believed they were still signed in. The UI flips to signed out at the same moment, and ADR 0034/0035 let that Guest's Games be claimed later. If you would rather keep writes failing, the retry could be limited to reads (GET procedures). I kept the ADR's wording as it stands.A smaller change: the Room stream used to reopen after its 2 s pause. The client now retries at once, inside the same open. An
UNAUTHORIZEDraised mid-stream, after the stream opened, now ends the following instead of reopening it. Auth is only checked when the stream opens, so this should never happen.Screenshots
Before is production, after is this merge request's review app at
1662221.Desktop
Mobile
mentioned in issue #458