Gitlab-runner: npm ci getaddrinfo EAI_AGAIN

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 failed, reason: getaddrinfo EAI_AGAIN

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

- init

  DIST_DIR: dist/mailadmin-frontend
  CLI_VERSION: 7.3.9

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

- cd /builds/dp/mailadmin-frontend/
- "[ -d node_modules ] || npm ci"
  stage: init
  image: trion/ng-cli:${CLI_VERSION}
  script: ['']
    policy: push
    key: ${CI_COMMIT_SHA}
    paths: ['mailadmin-frontend/node_modules']
  - 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 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