fix: connect server-backed CLI commands to the live webmux instance - #263
Conversation
Bun's fetch no longer throws "fetch failed" — it throws "Unable to connect. Is the computer able to access the url?" (code ConnectionRefused). formatServerError only matched "fetch", so when the webmux server isn't running, server-backed commands like `webmux oneshot` surfaced Bun's raw, confusing message instead of the friendly "Could not connect to webmux server on port N. Is it running?" hint. Match "Unable to connect" too, and add a shared.test.ts covering both the legacy and current Bun messages. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
webmux | 3a67ffb | Commit Preview URL Branch Preview URL |
Jun 01 2026, 03:51 PM |
|
Claude finished @rubenfiszel's task in 1m 23s —— View job Claude Code Review
SummaryTightly scoped fix that does exactly what the PR description claims. The user-visible bug was real (the LGTM to merge. A couple of optional observations below. Observations1. The same class of bug will likely recur (low-effort hardening available). 2. Substring breadth. 3. Test for the wrapper. Optional: Nits
|
|
Claude finished @rubenfiszel's task in 2m 56s —— View job Code Review — PR #263
Verdict: LGTMTightly scoped, correctly implemented, well-tested. No real bugs found. I traced the change through every caller ( The four new tests pin every branch of Observations (non-blocking)
Nothing actionable required. |
Summary
webmux oneshot --linear=<TEAM>failed withUnable to connect. Is the computer able to access the url?even though the webmux server was running — because it was running on port 5112 (awebmux serve --port 5112service), while the CLI hardcoded the 5111 default.Two root causes, both fixed here:
oneshot,linear,send) connect tohttp://localhost:<port>but only ever used--port/PORT/5111.webmux servewalks to a free port when 5111 is taken, so the live instance is often elsewhere. In-process commands (add,list,open, ...) talk to tmux/git/fs directly, which is whywebmux addworked whilewebmux oneshotdidn't.formatServerErroronly translated the old Bunfetch failedmessage into the friendly "Is it running?" hint. Current Bun throwsUnable to connect. Is the computer able to access the url?(codeConnectionRefused), which slipped through and was printed raw.Changes
bin/src/instance-port.ts(new):selectInstancePort(pure) +resolveLiveServerPort(I/O) resolve the port of the live webmux instance serving the current project from the instance registry, falling back to the sole live instance, then the default.bin/src/webmux.ts: when--port/PORTisn't set, resolve the live server port before dispatching CLI commands;--debuglogs the resolved source.serveis unaffected. Updated--porthelp text.bin/src/shared.ts:formatServerErrornow also recognizes Bun'sUnable to connectmessage.bin/src/instance-port.test.ts(project match, subdir match, preference, sole/default fallbacks, sibling-prefix guard) andbin/src/shared.test.ts(HTTP passthrough, legacy + current Bun connection messages, unrelated errors).Test plan
bun test bin/src/instance-port.test.ts bin/src/shared.test.tspasseswebmux serve --port 5112running for the current project,webmux oneshot --prompt 'x' --linear=TEAM(no--port) connects to 5112 instead of failing on 5111webmux --debug oneshot ...logsresolved port 5112 from live instance (project)Could not connect to webmux server on port 5111. Is it running?Generated with Claude Code