Yarn: always fail with slow internet, while npm does work

Created on 8 Dec 2016  路  24Comments  路  Source: yarnpkg/yarn

Hi folks, I ran out of my bandwidth and Internet speed reduces around 50KBps, yarn fails to install its components, while npm does work finally a little slower but it work.

Trace: 
   Error: getaddrinfo EAI_AGAIN registry.yarnpkg.com:443
     at Object.exports._errnoException (util.js:1026:11)
     at errnoException (dns.js:33:15)
     at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)

Let me know if any further input needed.

Most helpful comment

@jas99 Please don't post +1 comment. 馃憤 in the main post is enough.

All 24 comments

+1

@jas99 Please don't post +1 comment. 馃憤 in the main post is enough.

Just to add some detail: I had the same issue recently and after researching the error above it seems to be related to DNS resolution issues.

As the original reporter stated, npm seems to get around it and it shows some messages that it got the same error and it's trying to recover by retrying to fetch the packages.

I also experience the same issue, this is a screenshot of a recent occurrance:

image

It seems to be somewhat intermittent (almost 60% probability of happening).

This is my docker file:

WORKDIR /opt/app

RUN mkdir -p /opt
ADD yarn-v0.18.1.tar.gz /opt/
RUN mv /opt/dist /opt/yarn
ENV PATH "$PATH:/opt/yarn/bin"

ADD package.json yarn.lock /tmp/
RUN cd /tmp && yarn
RUN mkdir -p /opt/app && cd /opt/app && ln -s /tmp/node_modules
ADD . /opt/app
RUN cd /opt/app && yarn run gulp
RUN cd /opt/app && yarn run start

I'm havin the same error, though it has nothing to do with slow internet.

yarn-error.log - http://pastebin.com/WqCtY3Jr

This seems like dns resolutions error only, but again yarn is using the same repositories as npm.

@trodrigues most of the time yarn works but only sometime it sucks, and error is like, if it has to resolve 500 dependencies, it resolves around ~388/ ~400 / ~ 490 dependencies and then it sucks. I've tried couple of time, even by clearing cache and force options, no luck.
While it worked well with one npm install command, but the download was slow as of my internet.

Yep. Like I mentioned, the bug to me seems to be yarn failing to recover from these issues (which npm does fine).

yarn install v0.15.1
[1/4] Resolving packages...
[2/4] Fetching packages...
error getaddrinfo EAI_AGAIN registry.yarnpkg.com:443
    at Object.exports._errnoException (util.js:1023:11)
    at errnoException (dns.js:33:15)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
info Visit http://yarnpkg.com/en/docs/cli/install for documentation about this command.

happening again all the time today

Any updates on this issue? I do have the same problem

Same problem.

Same error, slightly different line numbers, possibly different version.

error getaddrinfo EAI_AGAIN registry.yarnpkg.com:443
    at Object.exports._errnoException (util.js:1036:11)
    at errnoException (dns.js:33:15)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
$ yarn --version
0.21.3

Edit: additional info: this is being run inside a Docker container as per https://hackernoon.com/using-yarn-with-docker-c116ad289d56#.qzivsu1td , so possibly related to https://github.com/yarnpkg/yarn/issues/1750?

I experienced this problem too. I ran yarn, got the error (yarn-error.log here), then immediately ran yarn again without changing anything and it worked.

Note that I was running yarn install on an empty project, not adding a package to an existing project.

I experienced it too, but setting the network-concurrency parameter to 1 solved it in my case:

yarn install --network-concurrency 1

I had this same issue running yarn in a docker container on Ubuntu 17.04, and found that, in my case, running dnsmasq as a service (for an unrelated project) was causing the containerized yarn install to throw this error. Stopping dnsmasq solved the issue.

I had this issue when doing a yarn install into the Docker base image alexsuch/angular-cli (1.2.1). I figured out that deleting local Docker image and restarting Docker solved the problem.

I suspect yarn keep failing because of the DNS record not found from the Docker image, for some reason (long Docker exec on my dev laptop can lead to little unwanted behaviours like these).

A quick & dirty fix is to add following line to your /etc/hosts file (*nix) or C:\Windows\System32\drivers\etc\ file (Windows):

AAA.BB.CC.DDD registry.yarnpkg.com

where AAA.BB.CC.DDD is the IP address currently mapped to the registry.yarnpkg.com domain. At the moment it's 104.16.63.173 but may change. You can get it from here for example: https://www.ultratools.com/tools/pingResult?hostName=registry.yarnpkg.com

docker-machine restart solved it in my instance.

Found that I received this message at a point when my internet connection went down. Maybe it's worth a connectivity check to display a more useful error?

This problem happen when you change your network, maybe from a wifi network to another one.
All you need to do is restart the docker service:
sudo systemctl restart docker

Same issue for me in docker. but outside the docker it works.

In my case, the solution was just restart docker, as suggested by @ryancastle and @leandrosilvaferreira.

Some sort of retry option would be very helpful for this issue.

--network-concurrency 1 didn't work for me, here's the workaround inspired by @avsd:

apt-get install -y bind9-host
registryYarnpkgComIpAddress=$(host registry.yarnpkg.com | awk '/has address/ { print $4 }' | head -n1)
echo "${registryYarnpkgComIpAddress} registry.yarnpkg.com" >> /etc/hosts
Was this page helpful?
0 / 5 - 0 ratings