Repository navigation
Preview follows the node that runs the session after a move - #174
Merged
Merged
Conversation
…'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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.servePreviewpicked 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:homeBackendasks 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 byservePreviewand byrouted(thehomedirof 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.Tests
TestThePreviewFollowsTheSessionWhenItMovedAndTheRouteIsStale(registry says gateway, route says worker; and the reverse),TestTheServersOwnPortIsRefusedForThePreview.gatewayandserverGo 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