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

Lines changed: 3 additions & 0 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy