Skip to content

Preview: find the session by its home name, try every place for a program, and log why it could not be reached - #175

Merged
vickeykumar merged 2 commits into
masterfrom
fix/preview-dialer-tries-every-place
Nov 23, 2026
Merged

vickeykumar merged 2 commits into
masterfrom
fix/preview-dialer-tries-every-place

Conversation

@vickeykumar

@vickeykumar vickeykumar commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Problem (critical)

After a session moved to a worker and back to the gateway, the Preview answered 502 on every port. Reproduced on a local gateway and worker (logs attached by the reporter).

Cause found with the new logging

  • Route by home name (gateway/router.go). PR 174 made the gateway ask the session registry where the session runs, but the registry names a home by its directory name (donadjdc, Config.HomeOf) while the Preview's token and the route table carry the path (/home/openrepl/donadjdc). homeBackend asked for the path only, never found the session and fell back to the stale route, so the Preview still went to the worker (the worker answered no process of donadjdc was found). It now asks for the path and for its base name. The test uses the registry's real naming and fails without the fix.
  • Dialer (server/preview.go). previewDialer chose ONE place for every port: one unsandboxed process in the server's own network sent every port to the real network. It now tries each place in turn (the namespace of each REPL that has one, the emulation's socket, then the real network for an unsandboxed process, never the site's own port).
  • Logging. A failing Preview logs why (at most once in 30 s per workspace and port): the processes found, each attempt and how it ended, and whether the emulation is on.

Tests

TestThePreviewFollowsTheSessionWhenItMovedAndTheRouteIsStale (registry naming as in production), TestAnUnsandboxedProcessDoesNotHideAnEmulatedProgram, TestAProgramInAnotherNamespaceIsReachedBeforeTheRealNetwork. gateway, server and livepreview Go tests pass. LLD 17.

Notes

A program does not move with the session: after a move, start the server again in the new terminal. Not tried on a worker with real cgroup namespaces (the dev container lacks CAP_SYS_ADMIN).

🤖 Generated with Claude Code

vickeykumar and others added 2 commits November 23, 2026 11:36
…ot reach it

previewDialer chose ONE place for every port: a single unsandboxed process in the server's own network (an admin's terminal opened in the workspace, a helper) sent every port to the machine's real network, where the program of a sandboxed REPL is not and, on a worker, the site itself listens on 8080. Now each place is tried in turn and the first that connects wins: the namespace of each REPL that has one, then the emulation's socket, then the real network (only for an unsandboxed process, never the site's own port).

A Preview that fails left no word in the log (502 on every port after a session moved to a worker, seen in a gateway and a worker log). It now logs, at most once in 30 seconds for a workspace and port, the processes found (with their network and sandbox state), each attempt and how it ended, and whether the emulation is on.

The facts the dialer asks of /proc and the namespaces are behind previewProc, which the tests replace: an unsandboxed process does not hide an emulated program, and a program in another namespace is reached before the real network. LLD 17.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The session registry names a home by its directory name (donadjdc, Config.HomeOf); the Preview's token and the route table carry the path (/home/openrepl/donadjdc). homeBackend asked the registry for the path only, never found the session and fell back to the stale route, so after a session moved back to the gateway the Preview still went to the worker (reproduced on a local gateway and worker: the worker answered 'no process of donadjdc was found'). It now asks for the path and for its base name. The test uses the registry's real naming and fails without the fix. LLD 17.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@vickeykumar vickeykumar changed the title Preview: try every place for a program, and log why it could not be reached Preview: find the session by its home name, try every place for a program, and log why it could not be reached Nov 23, 2026
@vickeykumar
vickeykumar merged commit 3eb36ac into master Nov 23, 2026
9 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