Skip to content

Commit

Permalink
fix(proxyReqWs): catch socket errors
Browse files Browse the repository at this point in the history
  • Loading branch information
chimurai committed Apr 20, 2022
1 parent f64c994 commit 3f48d50
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/_handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@ export function init(proxy: httpProxy, option: Options): void {
proxy.on(eventName, handlers[eventName]);
}

proxy.on('econnreset', (err, req, res, target) => {
logger.error(`[HPM] ECONNRESET: %s`, err);
// https://github.com/webpack/webpack-dev-server/issues/1642
proxy.on('econnreset', (error, req, res, target) => {
logger.error(`[HPM] ECONNRESET: %O`, error);
});

// https://github.com/webpack/webpack-dev-server/issues/1642#issuecomment-1104325120
proxy.on('proxyReqWs', (proxyReq, req, socket, options, head) => {
socket.on('error', (error) => {
logger.error(`[HPM] WebSocket error: %O`, error);
});
});

logger.debug('[HPM] Subscribed to http-proxy events:', Object.keys(handlers));
Expand Down

0 comments on commit 3f48d50

Please sign in to comment.