-
Notifications
You must be signed in to change notification settings - Fork 3.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
never get callback in some request #2475
Comments
In case of misunderstanding, for instance, I have called request(), say 1k times, but got 9997 responses. Does anybody have same problem? |
Same thing with us on the latest release. |
@derekseymour Hi, do you use proxy in your code? I'm not sure if it is a proxy issue. |
I have also noticed this, I'm running 2.75.0 Server-side logs show that a 200 OK response is indeed being sent back, but nothing is logged in the client application. The first thing the client does is log the response, so I'm fairly confident this isn't an application fail on my end. These requests are typically quick (load balancer logs suggest it took 88ms to from recv req -> fully send response) so I don't think timeouts are being hit. The one noticeable point here is that I sent 2 requests at virtually the same time: so I'm wondering if Sadly, this is a spectacular failure mode and has serious consequences for us, as we queue up requests and rely on requests either succeeding/failing/timing out in |
@kegsay I have this kind of problem only in the scenario of using proxy. There is no race condition for concurrent because in What I wonder is the timeout feature so I read the source code about timeout and found nothing incorrect. Timeout event would have happened on socket regardless of HTTP error in theory. Do you have any idea? @mscdex @simov |
@mike442144 I don't know anything about the proxy support. |
@mike442144 |
@kegsay Maybe you are right, I'll continue checking. |
any progress on this? I'm having the same issue with particular websites I'm making a get request to. |
@dish615 Do you use proxy? |
I've found the bug, it is in tunnel-agent. So if you are using proxy and your target website protocol is https, you would have the same problem. Below is the detail of the bug:
According to the nodejs manual, a tcp socket connection will be timed out before established by the operating system, but a http request never.So when you call reuqest() in request.js with proxy, request.js got a socket only tunnel-agent have a http connection with proxy. See the code below: // in tunnel-agent.js
connectReq.once('connect', onConnect)
//...
function onConnect(){
pending.request.onSocket(socket) // pending.request is an instance of ClientRequest
}
// in _http_client.js
function onSocket(socket){
req.emit('socket',socket); // request.js got the 'socket' event.
}
// in request.js
self.req.on('socket', function(socket) {
var setReqTimeout = function() {
self.req.setTimeout(timeout, function () {
if (self.req) {
self.abort()
var e = new Error('ESOCKETTIMEDOUT')
e.code = 'ESOCKETTIMEDOUT'
e.connect = false
self.emit('error', e)
}
})
}
} If tunnel-agent could not get a response for a 'connect' request, obviously request.js cannot get the connectReq.setTimeout(options.timeout || 15000, function(){
connectReq.abort();
}); That's all. I'll open a PR to the tunnel-agent.js. |
@simov What are you going to do? |
Same issue here! Thanks @mike442144 for your PR 👍 |
@lneveu You're welcome. |
Hello, Any news concerning this issue? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
not resolved, let's keep it open. refer to #2440 for more details. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I have about 10 million requests in a project, but I could never get response for some request.Here is my code:
I simplify the code for guys to better understand, let's call n("string") as "number of string" in log, then the problem is n("Requesting")>n("Requested")
What's your advice?
The text was updated successfully, but these errors were encountered: