Skip to content

Commit 425e833

Browse files
jonathannevedarrachequesne
authored andcommitted
fix: catch errors when destroying invalid upgrades (#658)
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.
1 parent 99adb00 commit 425e833

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Diff for: lib/server.ts

+3
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,9 @@ export class Server extends BaseServer {
678678
setTimeout(function() {
679679
// @ts-ignore
680680
if (socket.writable && socket.bytesWritten <= 0) {
681+
socket.on("error", e => {
682+
debug("error while destroying upgrade: %s", e.message);
683+
});
681684
return socket.end();
682685
}
683686
}, destroyUpgradeTimeout);

0 commit comments

Comments
 (0)