Skip to content

fix(devframe): bind a runtime-appropriate RPC WebSocket transport on Bun/Deno - #322

Merged
antfu merged 1 commit into
mainfrom
fix/bun-ws-transport
Sep 1, 2026
Merged

fix(devframe): bind a runtime-appropriate RPC WebSocket transport on Bun/Deno#322
antfu merged 1 commit into
mainfrom
fix/bun-ws-transport

Conversation

@antfubot

@antfubot antfubot commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

What

Fixes #317. instance-shell always loaded crossws's Node adapter, which refuses to run off Node, so the WebSocket RPC transport crashed on Bun and Deno — reproduced through @vitejs/devtools under bunx --bun vite-devtools.

How

The RPC socket binding is now chosen by runtime:

  • Side-car tier (devframe owns a dedicated server): binds crossws's Bun/Deno adapter over Bun.serve / Deno.serve for a real native WebSocket, keeping crossws's Node adapter on Node.
  • Shared-server tier (a foreign node:http server handed in — the Vite DevTools case): a foreign Node server can't be re-hosted natively, so on Bun/Deno it falls back to the runtime-agnostic SSE transport (already shipped), advertised as backend: 'sse'. On Node it is unchanged (native WebSocket).
  • attach / handleUpgrade (raw node:http upgrade) and a transportless shared server now raise clear diagnostics (DF0076 / DF0075) on Bun/Deno instead of the opaque crossws error.

The unbound tier is unchanged, so the existing hub-deno-minimal pattern (host wires its own native transport) keeps working.

Tests

Adds a cross-runtime RPC transport smoke test (packages/devframe/test/runtime-smoke.ts) that boots real initDevframe instances and drives one RPC round-trip through each binding — the native WebSocket side-car and the shared-server transport — under Node, Bun, and Deno. New CI runtime matrix job runs it on Bun and Deno; test:runtime / test:runtime:bun / test:runtime:deno scripts run it locally. Verified passing on Node, Bun 1.3, and Deno 2.

This PR was created with the help of an agent.

…Bun/Deno

The instance shell always loaded crossws's Node adapter, which refuses to
run off Node, so the WebSocket RPC transport crashed on Bun and Deno
(e.g. a hub mounted in Vite DevTools under `bunx --bun`).

Pick the binding by runtime instead: a side-car (where devframe owns a
dedicated server) now binds crossws's Bun/Deno adapter over Bun.serve /
Deno.serve for a real native WebSocket, and a shared foreign node:http
server (which can't be re-hosted natively) falls back to the runtime-
agnostic SSE transport. attach / handleUpgrade and a transportless
shared server surface clear diagnostics (DF0076 / DF0075) instead of the
opaque crossws error.

Adds a cross-runtime RPC transport smoke test run under Bun and Deno in
CI (and Node locally) to guard the binding.

Closes #317
@vercel

vercel Bot commented Sep 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
devframe Ready Ready Preview Sep 1, 2026 5:19am UTC
@antfu
antfu merged commit d6150dd into main Sep 1, 2026
13 checks passed
@antfu
antfu deleted the fix/bun-ws-transport branch September 1, 2026 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants