Closed lukekarrys closed 2 months ago
No pressure or anything, but.. I would like to add it has a "Prio 0" label at NPM. Just saying 😆 lol.
Meaning this issue is causing quite some problems on routes/switches/proxies/Jfrog Artifactory/NPM package repository and more. Both for individuals (at home) as well as in businesses alike. After all the huge amount of socket connections isn't scaling very well on consumer hardware or even server hardware.
Updated the reproduction to include sync and async versions of agent-base
and https-proxy-agent
as well because I wanted to see if that was also susceptible to this behavior since it also subclasses agent-base
.
Here's what I get when running it now:
❯ node index.js
core
10 max sockets
727 total versions
1873533 total bytes
----------------------------------------
agent-base-sync
591 max sockets
727 total versions
1873533 total bytes
----------------------------------------
agent-base-async
727 max sockets
727 total versions
1873533 total bytes
----------------------------------------
https-proxy-agent
548 max sockets
727 total versions
1873533 total bytes
----------------------------------------
When used with the
maxSockets
optionagent-base
creates more than that number of open sockets.This was found in
npm
which recently moved to usingagent-base
in v10 (https://github.com/npm/cli/issues/7072). Here's a comment from someone who debugged and found an incompatibility between how Node tracks open sockets and howagent-base
callssuper.createSocket
: https://github.com/npm/cli/issues/7072#issuecomment-2001980218.I was able to create a more minimal reproduction which I believe backs up that assertion. However, I'm happy to be told I'm holding it wrong too 😄
Reproduction