fails-components / webtransport

Http/3 webtransport support for node
Other
132 stars 20 forks source link

fix: check closed status of socket during callbacks #257

Closed achingbrain closed 4 months ago

achingbrain commented 4 months ago

Sometimes calling getSendQueueCount can cause an internal crash in the dgram module.

I think it may be because packets are being sent during server shutdown - guarding on the this.closed property similar to the sendPacket method avoids the crash.

TypeError: Cannot read properties of null (reading 'getSendQueueCount')
    at Socket.getSendQueueCount (node:dgram:995:36)
    at Http3WebTransportClientSocket.packetSendCB (file:///Users/alex/Documents/Workspaces/libp2p/js-libp2p-webtransport-listener/node_modules/@fails-components/webtransport-transport-http3-quiche/lib/socket.js:118:24)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)
martenrichter commented 4 months ago

Sure, I have also seen this. But it was during another problem, so I thought it was a side effect.

martenrichter commented 4 months ago

Sorry I did not think this through, I reverted the PR. This may cause promises to be not resolved. The protection must to be only in the check, if writes are blocked.

martenrichter commented 4 months ago

Btw, I think this is a bug, which also should be filed with node.js.