Gitlab-runner: npm ci getaddrinfo EAI_AGAIN registry.npmjs.org

I try to use a gitlab CI pipeline with my angular project in Docker.
But gitlab-runner fais with an error messagen when performing npm ci:

$ [ -d node_modules ] || npm ci
npm ERR! code EAI_AGAIN
npm ERR! errno EAI_AGAIN
npm ERR! request to https://registry.npmjs.org/@types/node/-/node-12.19.9.tgz failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org registry.npmjs.org:443

I am using a locally installed gitlab-ce instance.
Gitlab-ce Version: 13.7.3-ce.0
Gitlab-Runner: 13.7.0

That’s my Dockerfile:

FROM nginx:1.19.6-alpine
COPY nginx.conf /etc/nginx/nginx.conf
COPY /dist/frontend /usr/share/nginx/html

And that’s my gitlab-ci.yml

stages:
- init

variables:
  DIST_DIR: dist/mailadmin-frontend
  CLI_VERSION: 7.3.9

cache:
  key: ${CI_COMMIT_SHA}
  paths: ['mailadmin-frontend/node_modules']

before_script:
- cd /builds/dp/mailadmin-frontend/
- "[ -d node_modules ] || npm ci"
init:
  stage: init
  image: trion/ng-cli:${CLI_VERSION}
  script: ['']
  cache:
    policy: push
    key: ${CI_COMMIT_SHA}
    paths: ['mailadmin-frontend/node_modules']
  tags: 
  - docker

The EAI_AGAIN occurs when a getaddrinfo call (a DNS request to resolve a hostname to its IP) times out or is rejected by the DNS server it contacted.

Given the default NPM addresses in use, this appears to be an internet infrastructure driven issue. If this is frequent, you’ll need to figure out which DNS server the request hits by using a command such as dig registry.npmjs.org and try to run a local DNS cache service (such as dnsmasq) if the upstream DNS endpoint (such as the one provided by the ISP) is not reliable under load.

1 Like