Repository navigation
Conversation
…n Linux On Linux every sandboxed command runs in a network namespace of its own, so the dev app started inside the sandbox listened on a loopback the hub could not reach. The live-app host polled its URL forever and reported "Starting the app", and the coder's browser and page watcher, each in a wrap of their own, could not reach it either. Relay the app through a Unix socket in the sockets folder the wraps and the hub share: a socat inside the app's wrap serves its client port on the socket, a socat in this process serves the socket on a port picked once, and every other wrap gets a socat serving the socket on that same port, so one URL holds for the hub, the browser, the page watcher and the hub's own commands. The port survives restarts of the app, which the browser outlives. On macOS, where the wraps share the host's loopback, nothing changes. Closes #71
Contributor
|
#81 folded in all of #72's changes (
Since all of #72 is now on |
Contributor
Author
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.
Closes #71
Stacked on #66, which it shares the sandbox executor with; its base should move to
mainonce #66 merges.What changed
apps/hub/src/builds/posix-sandbox.ts: a newcreateAppRelaydecides how the dev app is reached from outside its wrap. On macOS, where every wrap shares the host's loopback, nothing changes. On Linux, where each wrap has a loopback of its own, the app is reached throughapp.sockin the sockets folder the wraps and the hub share:socatinside the app's wrap serves its client port on the socket;socatin this process serves the socket on a port picked once and kept across app restarts, and the app's URL names that port;socatserving the socket on that same port, so the one URL works there too.The executor gains an
appoption, and the sockets folder is created on Linux for app workspaces as it already was for the browser. Relays stop with the app and on dispose.apps/hub/src/builds/sidecar-tools.tsandapps/hub/src/live-app/host.tspassappfor app workspaces.Why
After the first build finished, the Live Preview stayed on "Starting the app" indefinitely. The app was up, but in network namespace 4026532474, while the hub polling its URL was in 4026532382. The coder's Playwright browser runs in a third namespace and could not reach the app either. Details in #71.
How it was verified
tsc --noEmit -p .passes;oxlint --deny-warningsand Prettier pass on the changed files;apps/hub/src/buildsandapps/hub/src/live-apptests pass.executor.app()returned a relayed URL, a fetch of it from outside the sandbox answered 200 within a second, and a probe command run throughexecutor.command()fetched the same URL from inside its own wrap and also got 200. The app's own log showed its client on a different port inside the sandbox, as expected.