Open the app's sockets against the server, so no proxy has to carry them - #421
Merged
davidmckayv merged 4 commits intoSep 8, 2026
Merged
Conversation
zopeVaibhav
requested review from
MikeRyanDev,
davidmckayv,
guidovizoso and
tylerslaton
as code owners
September 7, 2026 13:44
zopeVaibhav
force-pushed
the
fix/sockets-bypass-vite-proxy
branch
from
September 8, 2026 18:35
084adc3 to
644f6bb
Compare
zopeVaibhav
force-pushed
the
fix/sockets-bypass-vite-proxy
branch
from
September 8, 2026 19:32
644f6bb to
4a1a290
Compare
davidmckayv
approved these changes
Sep 8, 2026
davidmckayv
left a comment
Contributor
There was a problem hiding this comment.
Deep-reviewed against live code (correctness, governance, no vendor/secret/scale issues). Composed build+tests green. CHANGELOG/format rebase on CI-validated substance.
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.
What this changes
The app built both its WebSocket URLs from its own address, so both travelled through Vite's
/apiproxy. Under bun that proxy cannot carry a WebSocket (oven-sh/bun#24127, a regression since bun 1.3.1 whose fix is unmerged), so neither the Bot's screen nor live channel updates ever connected, and an upgrade the server answered with plain HTTP crashed the process serving the app.Both now address the server directly.
app/src/lib/socket-url.tskeeps the host the person actually used and changes only the port, so reaching the app at192.168.1.10:3010opens its socket at192.168.1.10:3001rather than somebody else's loopback. When no server port is configured it returns the page's own origin, so a deployment serving app and API from one origin is unchanged — pinned by a test.With nothing upgrading through the proxy,
ws: trueis no longer carrying anything, so it is gone. That is what removes the crash rather than a workaround for it: the branch containingsocket.destroySoon()is only reached when the proxy is asked to handle an upgrade.__OPENBOT_SERVER_PORT__is defined invite.config.tsfromSERVER_PORT, which is already in the environment Vite is started with, in dev and in theservescript the desktop shell runs.Fixes #420.
Where it runs
This is browser code choosing an address, plus one build-time constant.
Boundary and audit
/api/computers/<bot>/stream—resolveRequestActor, applied by hand because middleware does not run on an upgrade — is untouched and still runs.Changelog
CHANGELOG.mdunderUnreleased.Proof
Measured, not argued. The upstream cause, with a control that isolates the runtime:
Before and after, in a browser on the running app:
The live screen, on the endpoint the component now builds, against a running computer:
The crash, on both paths that serve the app, with the server up so the upgrade gets a real non-101 answer. Before, one request took both ports down and logged the
destroySoonTypeError. After:The one assumption worth stating was tested rather than reasoned about. Moving a socket to another port only works if the session cookie follows it, so a cookie was set on the page at
:3010and the server on:3001was instrumented to log what arrived on the handshake:Cookies ignore ports and the two are same-site, so the session reaches the guard exactly as before. The instrumentation was reverted; it is not in this branch.
App tests: 348 pass / 0 fail on
main, 352 pass / 0 fail here, the four new ones covering the address chosen.bun run typecheckclean acrossapp,serverandworker;biome lint --error-on-warningsclean over 575 files. The repository suite's handoff-queue lease tests fail on this branch and on a cleanmainalike, and their count moves between runs onmaintoo — they are not touched here.Not covered: this was verified on macOS with bun 1.3.14 and vite 7.3.6, and against a deployment with no identity provider configured, so the cookie above was a stand-in for a real session rather than one.