diff --git a/handlers.client.ts b/handlers.client.ts index b7ff619..968d37d 100644 --- a/handlers.client.ts +++ b/handlers.client.ts @@ -187,7 +187,12 @@ async function handleWebSocket( message: RequestStartMessage, state: ClientState, ) { - const ws = new WebSocket(new URL(message.url, state.localAddr)); + const target = new URL(message.url, state.localAddr); + // Coerce http(s): -> ws(s): so spec-strict runtimes (e.g. Bun) accept it. + // Node's undici silently rewrites the scheme, but Bun keeps `http:` and + // the handshake fails immediately, breaking HMR (Vite/Next) through the tunnel. + target.protocol = target.protocol === "https:" ? "wss:" : "ws:"; + const ws = new WebSocket(target); try { const wsCh = await makeWebSocket( ws, diff --git a/package-lock.json b/package-lock.json index e24e47c..b4778c5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@deco-cx/warp-node", - "version": "0.3.9", + "version": "0.3.21-debug.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@deco-cx/warp-node", - "version": "0.3.9", + "version": "0.3.21-debug.2", "license": "MIT", "dependencies": { "undici": "^6.21.0", @@ -22,7 +22,7 @@ "wrangler": "^3.91.0" }, "engines": { - "node": ">=20.0.0" + "node": ">=22.0.0" } }, "node_modules/@cloudflare/kv-asset-handler": {