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

Server can crash with WS_ERR_INVALID_OPCODE #392

Closed
jamesopti opened this issue Aug 29, 2022 · 0 comments · Fixed by #393
Closed

Server can crash with WS_ERR_INVALID_OPCODE #392

jamesopti opened this issue Aug 29, 2022 · 0 comments · Fixed by #393
Assignees
Labels
bug Something isn't working

Comments

@jamesopti
Copy link
Collaborator

Description
We've started to see an error occasionally in production that causes the Hocuspocus server to crash on a websocket error. Specifically, the error is:

/app/node_modules/@hocuspocus/server/node_modules/ws/lib/receiver.js:216
return error(
^
RangeError: Invalid WebSocket frame: invalid opcode 0
at Receiver.getInfo (/app/node_modules/@hocuspocus/server/node_modules/ws/lib/receiver.js:216:16)
at Receiver.startLoop (/app/node_modules/@hocuspocus/server/node_modules/ws/lib/receiver.js:136:22)
at Receiver._write (/app/node_modules/@hocuspocus/server/node_modules/ws/lib/receiver.js:83:10)
at writeOrBuffer (node:internal/streams/writable:389:12)
at _write (node:internal/streams/writable:330:10)
at Receiver.Writable.write (node:internal/streams/writable:334:10)
at Socket.socketOnData (/app/node_modules/@hocuspocus/server/node_modules/ws/lib/websocket.js:1231:35)
at Socket.emit (node:events:390:28)
at Socket.emit (node:domain:475:12)
at addChunk (node:internal/streams/readable:315:12) {

It appears that ws will catch this and close the connection if ws.on('error', cb) is defined, but I don't see that happening in the Hocuspocus source.

Steps to reproduce the bug
Unfortunately I'm not able to reproduce this yet. I tried sending some invalid websocket payloads to Hocuspocus but those appear to be filtered correctly.

Expected behavior
I would not expect ANY invalid websocket message from a single client to crash the server but rather log an error and close the offending connection.

Environment?

  • operating system: NodeJS 16
  • hocuspocus version: 1.0.0-alpha.100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants