Repository navigation
feat(adapter): add Bun WebSocket integration hooks - #7
Conversation
2b9fde4 to
67838d5
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2b9fde4b4b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const app = adapter.createApp(); | ||
| app.set?.("hostname", "127.0.0.1"); | ||
| adapter.configure(app, port); | ||
| app.get("/health", (_req, res) => { |
There was a problem hiding this comment.
Register the fallback endpoint through a router
When this test runs, adapter.createApp() returns BunApp, whose get(key) method reads application settings and overrides the inherited BunRouter.get(path, ...handlers) route-registration method. Consequently this call does not register /health, and bun test tests/BunWebSocketAdapter.test.ts deterministically receives 404 at the fallback assertion. Create a router with adapter.createRouter(), register the route there, and mount it with app.use(...) as the production modules do.
Useful? React with 👍 / 👎.
|
🎉 This PR is included in version 1.3.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
BunWebSocketAdapterfor libraries that need direct access to Bun's nativefetchandwebsockethandlersbeforeFetchbefore the normal Bun Platform Kit router and exposesnext()as the HTTP fallbackBunAdapterandBunKitServerbehavior unchanged@socket.io/bun-engineWhy
Socket.IO's Bun engine must participate directly in
Bun.serve({ fetch, websocket }). The current service lifecycle only receives the frameworkServerInstance, which is not a Nodehttp.Server, so Node-stylenew SocketIOServer(httpServer)cannot handle WebSocket upgrades.Validation