-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I filter socket hang up errors? #813
Comments
+1 |
+1 |
You should be able to use the proxy error event or the error callback and check for res.socket.destroyed === true and error.code === ECONNRESET which means the request was canceled |
Merci @vvo ;) Will try that asap |
Yes it depends on the use case, sometime you will want the error to pop out if the client canceled the request. |
What I thought. Closing it then. |
Quick question again: I want to use request abort to prevent the underlying server to handle that client cancelled request. But, very surprisingly, Any thoughts? |
nope sorry, |
I think the |
Ok for the record, in case anyone was interested at doing the same thing How to catch request client cancelled and abort ongoing proxied requestproxy.on('proxyReq', function(proxyReq, req) {
// keep a ref
req._proxyReq = proxyReq;
});
proxy.on('error', function(err, req, res) {
if (req.socket.destroyed && err.code === 'ECONNRESET') {
req._proxyReq.abort();
}
}); |
This is a bug and should be fixed within |
Which one? Getting all errors even from client cancelled request or be forced to tricky save |
@JSteunou To put it simply, your workaround here should be handled within |
Would be nice :) |
@JSteunou Pull requests always welcome if you want to take a stab at it! :) |
also @vvo if you want the error handled, you could handle the error directly on |
Yep makes sense |
@jcrugzz I'm afraid I have the necessary solution and motivation but not the time to do it. |
Fairly old thread, but still an issue afaik. Resolving it by comparing the error code to Would be happy to submit a PR to handle this exception internally, but aren't there any use cases where you'd actually want to handle this manually? At the very least you'd need to emit a new event instead ( |
ECONNRESET means the other side of the TCP conversation abruptly closed its end of the connection. If we get an ECONNRESET error from the proxy request and the socket is destroyed this means that the client has closed his connection, and emit this as an error can lead to confusion and hacks to filter that kind of message. I think that the best we can do is abort and emit another event, so if any caller wants to handle with that kind of error, he can by listen the disconnected event. http-party#813
mark |
* Emit disconnected event instead of error when ECONNRESET ECONNRESET means the other side of the TCP conversation abruptly closed its end of the connection. If we get an ECONNRESET error from the proxy request and the socket is destroyed this means that the client has closed his connection, and emit this as an error can lead to confusion and hacks to filter that kind of message. I think that the best we can do is abort and emit another event, so if any caller wants to handle with that kind of error, he can by listen the disconnected event. #813 * code standards, move econnreset check, change ev name
Should we consider this closed? |
I'm using node-http-proxy for a while now, and I think I'm using it quite right catching errors like this
But I can have two cases that make a "socket hang up" error happen.
Watching at my log I can make no differences between those two cases and it's quite frustrating. Before knowing about request abort (thank #527) I really though I have an error going on.
So, what's the best practice to filter the request.abort case out?
The text was updated successfully, but these errors were encountered: