From 1aaf330fa6be66385168bdfcd5c540a070ea225a Mon Sep 17 00:00:00 2001 From: Levente Pleszkats Date: Thu, 7 Mar 2024 06:23:16 +0100 Subject: [PATCH] fix(proxyReqWs): catch socket errors on 0.19.2 --- lib/index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/index.js b/lib/index.js index 8da73048..b29d38bc 100644 --- a/lib/index.js +++ b/lib/index.js @@ -33,6 +33,14 @@ function HttpProxyMiddleware(context, opts) { // log errors for debug purpose proxy.on('error', logError) + proxy.on('econnreset', (err, req, res, target) => { + logger.error(`[HPM] ECONNRESET: %s`, err.message); + }); + proxy.on('proxyReqWs', (proxyReq, req, socket, options, head) => { + socket.on('error', (error) => { + logger.error(`[HPM] WebSocket error: %s`, error.message); + }); + }); // https://github.com/chimurai/http-proxy-middleware/issues/19 // expose function to upgrade externally