Originally reported by @k161196 in #197.
All community-submitted pull requests are automatically converted to issues (bugs) & discussions (feature requests, enhancements) where they can be triaged and prioritized. Once prioritized, a PR implementation is created automatically.
Describe the Bug
Node-target builds (@flue/cli) return HTTP 500 on every WebSocket upgrade request to /agents/:name/:id. The root cause is a dual-instance Symbol mismatch: @flue/cli bundles @hono/node-server into the generated dist/server.mjs, while the generated entry also imports createNodeWebSocketTransport from @flue/runtime/node (kept external), which re-imports upgradeWebSocket from a separate disk copy of @hono/node-server. The two module instances produce two distinct WAIT_FOR_WEBSOCKET_SYMBOL identities — injectWebSocket writes symbol A onto env, but upgradeWebSocket reads symbol B, finds undefined, and returns new Response(null, { status: 500 }). The same dual-copy problem applies to the ws package.
Expected Behavior
WebSocket upgrade requests to /agents/:name/:id on node-target builds should complete successfully with a 101 Switching Protocols response, allowing the SDK client to stream events over the connection.
Steps to Reproduce
- Build a Flue project targeting Node (e.g., starting from
examples/hello-world/ with the node target configured).
- Start the built server from
dist/server.mjs.
- Attempt a WebSocket connection to
/agents/:name/:id (e.g., via the SDK client or a WebSocket tool).
- Observe that the server responds with HTTP 500 instead of upgrading the connection.
Original implementation from #197 by @k161196
Describe the Bug
Node-target builds (
@flue/cli) return HTTP 500 on every WebSocket upgrade request to/agents/:name/:id. The root cause is a dual-instance Symbol mismatch:@flue/clibundles@hono/node-serverinto the generateddist/server.mjs, while the generated entry also importscreateNodeWebSocketTransportfrom@flue/runtime/node(kept external), which re-importsupgradeWebSocketfrom a separate disk copy of@hono/node-server. The two module instances produce two distinctWAIT_FOR_WEBSOCKET_SYMBOLidentities —injectWebSocketwrites symbol A ontoenv, butupgradeWebSocketreads symbol B, findsundefined, and returnsnew Response(null, { status: 500 }). The same dual-copy problem applies to thewspackage.Expected Behavior
WebSocket upgrade requests to
/agents/:name/:idon node-target builds should complete successfully with a 101 Switching Protocols response, allowing the SDK client to stream events over the connection.Steps to Reproduce
examples/hello-world/with the node target configured).dist/server.mjs./agents/:name/:id(e.g., via the SDK client or a WebSocket tool).Original implementation from #197 by @k161196