64

I'm currently using Yarn on a very unstable internet connection. Sometimes it takes hours until I can finally download all the packages.

I noticed Yarn retries the download when there is some kind of the internet connection:

[1/4] Resolving packages...
31-Dec-1969 21:00:00    [INFO] info There appears to be trouble with your 
network connection. Retrying...
31-Dec-1969 21:00:00    [ERROR] error An unexpected error occurred: 
"https://github.com/flot/flot: getaddrinfo EAI_AGAIN github.com:443".

Is it possible to retry forever until it downloads or increase the timeout?

Something like {timeout: 9999999}

aioobe
  • 413,195
  • 112
  • 811
  • 826
Fabio K
  • 1,297
  • 4
  • 13
  • 24

2 Answers2

122

Try using the network-timeout flag with a delay in milliseconds, like this:

yarn install --network-timeout 1000000000

Crono
  • 10,211
  • 6
  • 43
  • 75
27

You can configure it with this:

yarn config set network-timeout 600000 -g

Newer version of yarn use this:

yarn config set httpTimeout 600000
olawalejuwonm
  • 1,315
  • 11
  • 17
  • Haven't tried this myself but if it does work as it suggests, then this should become the accepted answer. Out of curiosity, is there any documentation about this on Yarn's website? Does it work with Yarn 2 only or was it always sitting there? – Crono Nov 26 '20 at 13:11
  • it doesn't come up from yarn --help, but there is a docs page: https://classic.yarnpkg.com/en/docs/cli/config/ – nruth Jan 18 '21 at 20:31
  • 2
    Newer versions of yarn use `yarn config set httpTimeout 600000` - https://github.com/yarnpkg/berry/pull/1291 – Jaybird Sep 18 '22 at 22:36
  • @Jaybird have you confirmed that, should i update the answer? – olawalejuwonm Sep 19 '22 at 19:37