Skip to main content
← Back to list
01Issue
BugOpenSwamp CLIPublic
AssigneesNone

Relationships

#4894 A host's router turns a child's refused WebSocket into 502, hiding why the workspace or root refused it

Opened by zack · 11/19/2026

Problem

The host's router (src/serve/host/workspace_router.ts, relayWebSocket) opens its own WebSocket to the child serve. Deno's WebSocket client hides a refused handshake's status, so any refusal by a workspace or the root reaches the caller as 502 "The workspace could not be reached."

Behind a host, a refused or expired workspace token, a rate limit (429), an origin refusal (403) and a misdirected request (421) on the WebSocket all read as a server error, and the CLI's login hint never shows. The CLI cannot tell a refused credential from a crashed child.

swamp-club#4877 works around this for workspace sign-in only: it asks the root's HTTP route (whose status the router's HTTP forwarder passes on) whether the host token was refused. A workspace token the workspace refuses before its expiry still reads as 502.

What did not work

A re-ask of the child over HTTP without the caller's credentials (tried and reverted in #4877): a serve answers any upgrade without credentials with 401 "token required" before its rate limits and origin checks, so the re-ask returns 401 for nearly every refusal. A busy root then read as a refused sign-in. Re-asking with the caller's credentials double-counts a failed attempt and, after a transient failure, completes an extra authenticated upgrade.

Possible fixes

  • Do the upstream handshake over a raw connection so the router reads the child's status line, and relay frames itself after a 101.
  • Or have the child mark the refusal in a way the router can read without a second credentialed request.

Done when

A child's 401, 403, 421 or 429 on a WebSocket reaches the caller through the host with that status, a refused credential is never sent twice, and the router tests use a child whose status depends on the credentials it receives, as a real serve's does.

02Bog Flow
◉OPEN○TRIAGED○IN PROGRESS○SHIPPED

Open

11/19/2026, 3:43:13 AM

No activity in this phase yet.

03Sludge Pulse

Sign in to post a ripple.