Closed codeofmochi closed 3 years ago
Indeed, the bug was caused by conn.destroy(error)
.
The Stream.Readable API (https://nodejs.org/api/stream.html#stream_readable_destroy_error) raises the passed error optionally. We don't need the error to be processed by the stream itself, so we should just destroy the connection without passing the error.
Hence fix is https://github.com/graasp/graasp-websockets/commit/16670d7339a19ec407367955a6c668548b950344
When running the graasp server with the graasp-websockets plugin, accessing the websocket endpoint crashes the server if accessed using a websocket connection without a valid sesion.
If accessed through HTTP, no error is raised and the server doesn't crash. If accessed through WS, the whole process crashes with error:
Thus the error is probably in the errorHandler passed here: https://github.com/graasp/graasp-websockets/blob/4a55f781d29f49c0ff5766052d7f27f8fcc53f81/src/service-api.ts#L53-L58