From 46d02be9533cc800e32b0df510149ca35e7453cb Mon Sep 17 00:00:00 2001 From: caoshanmin Date: Thu, 2 Jan 2020 10:41:35 +0800 Subject: [PATCH] fix(#1342): pipe-writing for opening-socket --- 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..6f261e152 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 === socket.OPEN) { socket.write(createHttpHeader('HTTP/' + res.httpVersion + ' ' + res.statusCode + ' ' + res.statusMessage, res.headers)); res.pipe(socket); }