From 0f239307dbe6f4520eb7715529c595eedba0b050 Mon Sep 17 00:00:00 2001 From: Roderik van der Veer Date: Thu, 25 Nov 2021 14:56:46 +0100 Subject: [PATCH] backport https://github.com/http-party/node-http-proxy/pull/1552 --- lib/http-proxy/passes/ws-incoming.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/http-proxy/passes/ws-incoming.js b/lib/http-proxy/passes/ws-incoming.js index 270f23f45..e5787f297 100644 --- a/lib/http-proxy/passes/ws-incoming.js +++ b/lib/http-proxy/passes/ws-incoming.js @@ -111,7 +111,7 @@ module.exports = { proxyReq.on('error', onOutgoingError); proxyReq.on('response', function (res) { // if upgrade event isn't going to happen, close the socket - if (!res.upgrade) { + if (!res.upgrade && socket.readyState !== "closed") { socket.write(createHttpHeader('HTTP/' + res.httpVersion + ' ' + res.statusCode + ' ' + res.statusMessage, res.headers)); res.pipe(socket); }