Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSockets error: TypeError: null is not an object (evaluating 'res.status') #27

Open
ncpa0cpl opened this issue Jan 14, 2024 · 1 comment

Comments

@ncpa0cpl
Copy link

WebSockets always throw errors when attempting to connect:

129 |                 message: (ws, msg) => router.handleWebSocket(ws).message(msg),
130 |             },
131 |             async fetch(req, server) {
132 |                 let ctx = new Context(req, server);
133 |                 const res = await router.handle(ctx);
134 |                 return res.status === 404 ? notFoundHandler(ctx) : res;
                             ^
TypeError: null is not an object (evaluating 'res.status')
      at node_modules/baojs/dist/bao.js:134:24

All I've done here is setup a simple websocket connection:

app.ws("/ws/room", {
  close(ws) {
  },
  message(ws, msg) {
  },
  open(ws) {
  },
});

It looks like the route handler doesn't create any Response object, but the fetch() method expects one to always be present.

Bao version: 0.2.1
Bun verions: 1.0.18

@lazuee
Copy link

lazuee commented Mar 29, 2024

This pull request #30 will fix that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants