fix(client): coerce ws scheme on forwarded upgrade target (fixes #1)#2
Merged
Conversation
`new URL(message.url, state.localAddr)` yields an `http(s):` URL; Node's undici silently rewrites the scheme but Bun's spec-strict WebSocket rejects it, breaking every forwarded WebSocket (Vite/Next HMR) under Bun. Coerce to `ws(s):` before constructing the WebSocket. Also sync package-lock.json to match package.json (version + engines). Fixes #1 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
tlgimenes
added a commit
that referenced
this pull request
May 22, 2026
`new URL(message.url, state.localAddr)` yields an `http(s):` URL; Node's undici silently rewrites the scheme but Bun's spec-strict WebSocket rejects it, breaking every forwarded WebSocket (Vite/Next HMR) under Bun. Coerce to `ws(s):` before constructing the WebSocket. Also sync package-lock.json to match package.json (version + engines). Fixes #1 Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
4 tasks
tlgimenes
added a commit
to decocms/studio
that referenced
this pull request
May 22, 2026
0.3.20 passes an `http:`-scheme URL to `new WebSocket(...)` when forwarding upgrades in `handlers.client.ts`. Node's undici silently rewrites it to `ws:`, but Bun keeps the scheme and the handshake fails immediately — so every WebSocket through the link tunnel (Vite HMR, Next.js webpack-hmr/Turbopack HMR) dies before connecting when the link daemon runs under Bun, which it always does via `bunx decocms link`. Upstream fix: deco-cx/warp-node#2, released in 0.3.22/0.3.23. Issue: deco-cx/warp-node#1. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Fixes #1 — WebSocket upstream URL not coerced to
ws://, HMR fails under Bun.handleWebSocketinhandlers.client.tswas passing anhttp(s):-scheme URL straight tonew WebSocket(...). Node's built-in WebSocket (undici) silently rewrites the scheme tows:, so it worked there — but Bun keeps thehttp:scheme and the handshake fails immediately, killing every WebSocket forwarded through the tunnel.In practice this broke any dev-server feature that rides a WebSocket (Vite HMR, Next.js webpack-hmr / Turbopack HMR) when the warp client ran under Bun — including
bunx decocms link.Change
In
handlers.client.ts, coerce the URL's protocol fromhttp(s):→ws(s):before constructing the WebSocket:Behavior under Node is unchanged (undici was already doing this conversion); Bun and any spec-strict runtime now work correctly.
Also includes a
package-lock.jsonsync to matchpackage.json(version + Node engines bump that was already in the lockfile-adjacent state).Files
handlers.client.ts— scheme coercion + explanatory commentpackage-lock.json— version/engines syncTest plan
npm run typecheck— cleannpm test— 14/14 passing (vitest)bunx decocms linkagainst a Next.js / Vite dev server and confirm HMR WebSockets connect through the tunnel (previously failed before handshake under Bun)🤖 Generated with Claude Code