Skip to content

Preview follows the node that runs the session after a move - #174

Merged
vickeykumar merged 1 commit into
masterfrom
fix/preview-route-after-move
Nov 23, 2026
Merged

vickeykumar merged 1 commit into
masterfrom
fix/preview-route-after-move

Conversation

@vickeykumar

Copy link
Copy Markdown
Owner

Problem (critical)

Reported with a gateway log and a worker log: after a session moved between the gateway and a worker (and back), the Preview showed 502 "Nothing is running yet" with the program (pydoc, http.server) listening on the other node. The worker log shows the gateway still sending /preview/... requests to it (preview: no process of donadjdc was found for port 8080) while the gateway log shows the new terminals running on the gateway.

Cause

Router.servePreview picked the node from the route table (RouteHome), which is filled by announcements of the workers and emptied only by their "closed" announcement. A move can leave the old entry behind.

Fix

  • gateway/router.go: homeBackend asks the session registry first (SessionRegistry.HomeOwner: the live session that uses the home), drops a route entry that disagrees, and falls back to the route table only when no live session uses the home. Used by servePreview and by routed (the homedir of a shared session's file requests).
  • server/preview.go: an admin's REPL listens on the real network, where the site itself is; the Preview refuses the server's own port for it (isOwnPort) instead of showing OpenREPL in the frame.
  • LLD 17, "Routing after a session moves".

Tests

TestThePreviewFollowsTheSessionWhenItMovedAndTheRouteIsStale (registry says gateway, route says worker; and the reverse), TestTheServersOwnPortIsRefusedForThePreview. gateway and server Go tests pass.

Not confirmed

How a Preview of port 8080 showed the OpenREPL page after the move (the worker's own server listens on 8080): the own-port refusal covers the admin path only. Not tried with a real gateway and worker. After a deploy, retest: pydoc on the gateway, move to the worker, move back, open the Preview. If OpenREPL still shows, the new worker log line tells more.

🤖 Generated with Claude Code

…'s Preview refuses the site's own port

The gateway sent /preview/<token>/... to the node the route table named for the workspace. The table is filled by announcements of the workers and emptied by their 'closed' announcement, so a session that moved (to a worker, back to the gateway) could leave the old entry behind: the Preview kept asking the node that no longer ran the program and showed 'Nothing is running yet' with the program listening on the other node (seen in a gateway and a worker log). Router.homeBackend asks the registry first (the live session that uses the home), drops a route entry that disagrees with it, and falls back to the table only when no live session uses the home. The homedir of a shared session's file requests (routed) uses it too.

An admin's REPL listens on the real network, where the site itself is: the Preview refuses the server's own port for it instead of showing the site in the frame.

LLD 17. Tests: the move with a stale route, and the own-port check.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@vickeykumar
vickeykumar merged commit 5e7586e into master Nov 23, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant