-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
http.Agent keepAlive connection pooling broken #52299
Comments
The behavior you’re reporting makes sense to me as you’re not consuming the response body of the first request (the first argument to the callback, which you are not using) before making the second. |
By calling the resume() method on the http.IncomingMessage objects (response1 and response2), you ensure that the response bodies are consumed, allowing the connections to be reused properly. This should result in only one socket being open at the conclusion of the second request. |
Thx @isker and @Malikrehman00107, my mistake. |
Version
v20.12.0
Platform
Linux ip-xxx 6.5.0-1014-aws #14~22.04.1-Ubuntu SMP Thu Feb 15 15:27:06 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
http
What steps will reproduce the bug?
Create an http.Agent with keepAlive: true, make a request to a given host, after that request succeeds, make a second request to the same host, after that request succeeds, observe open sockets.
test.js
:How often does it reproduce? Is there a required condition?
100%
What is the expected behavior? Why is that the expected behavior?
Only one socket is open at the conclusion of the second request. The second request should reuse the first socket due to
keepAlive: true
being set on the agent.What do you see instead?
Two sockets are open at the conclusion of the second request
Additional information
This appears to be a regression some time during node v10:
for i in 20 10 9 8; do nvm use $i; node test.js; echo "------------------"; done
:The text was updated successfully, but these errors were encountered: