node-http-proxy icon indicating copy to clipboard operation
node-http-proxy copied to clipboard

Specific error for timeouts

Open pablote opened this issue 6 years ago • 2 comments
trafficstars

I'm currently proxying requests like this:

this._proxy.web(req, res, { target: target.host, proxyTimeout }, err => {
				logger.error("Error proxying %s -> { Host: %s, URL: %s }: ", req.originalUrl, target.host, target.requestURL);
				logger.error(err);
				res.status(500).send();
			});

If the upstream server takes too long, the callback is run with the following error:

2019-03-28T19:49:22.165Z - error:  message=socket hang up, stack=Error: socket hang up
    at createHangUpError (_http_client.js:331:15)
    at Socket.socketCloseListener (_http_client.js:363:23)
    at emitOne (events.js:121:20)
    at Socket.emit (events.js:211:7)
    at TCP._handle.close [as _onclose] (net.js:557:12)
, code=ECONNRESET

Would it make sense to get a timeout specific error? so I can, if I chose to do so, return a specific timeout error like 504?

pablote avatar Mar 28 '19 19:03 pablote