alanshaw / it-ws

🕸 🔌 Simple async iterators for websocket client and server connections
Other
11 stars 11 forks source link

onWsServerConnection yields null pointer exception #114

Closed marcus-pousette closed 3 months ago

marcus-pousette commented 3 months ago

Null pointer exception handling address

 Uncaught TypeError: Cannot read properties of null (reading 'address')
      at Server.onWsServerConnection (file:///home/runner/work/peerbit/peerbit/node_modules/it-ws/src/server.ts:81:26)
      at WebSocketServer.emit (node:events:519:28)
      at WebSocketServer.emit (node:domain:488:12)
      at WebSocketServer.completeUpgrade (/home/runner/work/peerbit/peerbit/node_modules/ws/lib/websocket-server.js:436:5)
      at WebSocketServer.handleUpgrade (/home/runner/work/peerbit/peerbit/node_modules/ws/lib/websocket-server.js:344:10)
      at Server.upgrade (/home/runner/work/peerbit/peerbit/node_modules/ws/lib/websocket-server.js:119:16)
      at Server.emit (node:events:519:28)
      at Server.emit (node:domain:488:12)
      at onParserExecuteCommon (node:_http_server:939:14)
      at onParserExecute (node:_http_server:840:3)

Seems like ws types are wrong. Address can indeed be null:

https://github.com/websockets/ws/blob/019f28ff1ffddfcdc428d1de5ecd98648057a2ab/lib/websocket-server.js#L148C31-L148C35

I seem to be able to trigger this issue sometimes when I start and stop servers and make connections. But can not do reproduce this in an accurate way