Skip to content

Commit 83c4071

Browse files
fix: catch errors when destroying invalid upgrades
Before this change, receiving an HTTP2 upgrade would make the server crash: > Error: read ECONNRESET > at TCP.onStreamRead (node:internal/stream_base_commons:217:20) { > errno: -104, > code: 'ECONNRESET', > syscall: 'read' > } This can be reproduced with Node.js v14.15.3, v16.18.1 and v18.12.1. Backported from 425e833
1 parent f62f265 commit 83c4071

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/server.js

+3
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,9 @@ Server.prototype.attach = function (server, options) {
487487
// then the socket needs to die!
488488
setTimeout(function () {
489489
if (socket.writable && socket.bytesWritten <= 0) {
490+
socket.on('error', e => {
491+
debug('error while destroying upgrade: %s', e.message);
492+
});
490493
return socket.end();
491494
}
492495
}, destroyUpgradeTimeout);

0 commit comments

Comments
 (0)