-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
I've been getting some strange ECONNREFUSED errors when trying to use yarn or npm inside Docker ( and Docker edge build ), an issue that is somehow still unknown of origins.
What is the current behavior?
When doing an yarn install/add or npm install, you start seeing ECONNREFUSED 151.101.36.162:443 on random packages. Verbose output shows that once the first ECONNREFUSED error happens, all the following requests will start failing with the same reason. Note that the error happens randomly on any package, there is no specific package or url causing it as far as I know.
Steps to reproduce.
It's pretty hard to reproduce, and from reading other people's similar issues, it doesn't seem to be related to the OS. One odd behavior I have noticed, is that, using the same machine with the same setup, I do NOT get this issue when I'm connected my work's network ( physically in a different place ), but I do get it at home. My friend's (windows) PC, which's also connected to the same home network as me, does not get this problem, but both of my own PCs do (both windows).
What is the expected behavior?
Yarn install should simply install the packages just like it's supposed to.
Solution
Setting an argument --network-concurrency=1 solves this issue entirely.
Proposed change
In case of consecutive ECONNREFUSED errors, falling back to network-concurrency=1 with a delay would solve this for me and many others. Perhaps a message proposing this argument is gonna prevent users from getting this confusing error.
Tested this issue on these following systems:
Happens with yarn(1.3.2) and npm (5.6.0) and possibly older versions.
Node 9.2, 8.9 and Node 6.x.
Windows 10 ( cleanly installed build 16299 and an existing 17074 build ) with Docker CE ( older version 16.x, stable 17.12.x and edge 18.01.0 )
To do later
I'll test yarn again with 1.4.0 later this evening to see if this issue persists.