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
Fixing socket hang up error on node side for slow response. #1752
Conversation
@mzabriskie can you help me? |
@nickuraltsev could you help me? |
It looks like request.setTimeout sets a read timeout handler on the underlying socket. It's not the same thing as a request timeout. Is the issue is that aborting a request before the connection is established doesn't properly dispose of the socket? |
@RikkiGibson Yes,abort a request before the connection, and does not release socket. When the server side is too slow and no responed for a long time, sometimes setTimeout will be invoked before connection, and "socket hang up" will be got. This only appear at connection does not block setTimeout. I think for Borwser the request timeout is not the same as connection timeout, But on nodejs I think it is the same. and sometimes the connection block setTimeout. So if we set 10s for timeout ,but the connection block the event loop about 20s, the setTimeout will be fire after 20s. poll: retrieve new I/O events; execute I/O related callbacks (almost all with the exception of close callbacks, the ones scheduled by timers, and setImmediate()); node will block here when appropriate. |
The request timeout applies to receiving the entire HTTP response. The socket timeout, set by request.setTimeout, applies to any activity on the socket (individual reads and writes). The browser doesn't provide any way to set this. I said "read timeout" previously because a lot of languages will let you configure read and write timeouts separately, while node appear to combine them into one. Sorry for any confusion. Let's use the if (request.socket.connecting) {
request.socket.on('connect', function() {
request.abort();
}
} else {
request.abort();
} Does that seem reasonable? |
@RikkiGibson Thank you for your explain, Maybe my english is not good enough. Yes you want to do timeout like borwser .But sometimes the io event will block setTimeout. the setTimeout will not be invoked in time. for my case like I said before:
So, when connection block setTimeout function, The timeout will be fired more than millseconds you set before. This is my problem. |
Nobody else? |
I have this issue as well. We have plenty of requests open at the same time |
Hi there, Is there any updates on this PR? I think I'm suffering from the same problem. Thanks |
I have the same question...... |
mark |
Any update? |
I have the same question |
mark |
Is any priority going to be given to this issue? I'm hitting this in production and it's forcing us off axios. |
this pr need another code review |
My issue
I think this issue is the same reason