Closed misterbyrne closed 8 years ago
Update: after more tests - this time with nettop
and a small value for maxConnections
, I could see that passing the agent to request was, in fact, working okay. I looked at request's source code and can see that while the previous approach was having the desired effect - it was more of a side-effect than this approach.
Also, PR for the npm
side is here: https://github.com/npm/npm/pull/11666
Looks great! Landed as 3aeca7a and published in v7.1.0
NPM installs are failing all the time for installs of large shrinkwrapped projects on my home (wifi) network. It tends to work on a wired network. I figured out that this was due to the large number of connections that npm makes to the registry. Inflating a shrinkwrap results in a request being made to the registry for each item in the dependency tree - and because of npm3's flat file structure, almost all of them happen at once.
This PR makes use of
request'sthe agent'spool
option, along withmaxSockets
option to use client connection pooling which drastically reduces the number of outgoing connections, resulting in a quicker and more stable install.It looks like this should fix some issues people are having with installing lots of dependencies over consumer network hardware / crappy internet connections / environments with limited resources.