3

I have a basic angular project with two submodules that runs and build perfectly fine on my computer, but fails immediately on gitlab ci. The build is done inside a docker container, as seen below :

image: node:16-alpine
before_script:
  - apk update
  - apk add git
  - git submodule update --init --recursive

build:
  only:
    - develop
  script:
    - npm ci
    - npm run build
$ npm ci
npm ERR! code EPIPE
npm ERR! syscall write
npm ERR! errno -32
npm ERR! write EPIPE
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-10-17T09_20_04_458Z-debug-0.log

Edit : with --verbose

 npm http fetch POST 400 http://153.89.23.53:8082/repository/npm-all/-/npm/v1/security/audits/quick 106ms
npm verb audit error HttpErrorGeneral: 400 Bad Request - POST http://153.89.23.53:8082/repository/npm-all/-/npm/v1/security/audits/quick
npm verb audit error     at /usr/local/lib/node_modules/npm/node_modules/npm-registry-fetch/lib/check-response.js:95:15
npm verb audit error     at processTicksAndRejections (node:internal/process/task_queues:96:5)
npm verb audit error     at async Map.[getReport] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/audit-report.js:335:21)
npm verb audit error     at async Map.run (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/audit-report.js:106:19)
npm verb audit error  HttpErrorGeneral: 400 Bad Request - POST http://153.89.23.53:8082/repository/npm-all/-/npm/v1/security/audits/quick
npm verb audit error     at /usr/local/lib/node_modules/npm/node_modules/npm-registry-fetch/lib/check-response.js:95:15
npm verb audit error     at processTicksAndRejections (node:internal/process/task_queues:96:5)
npm verb audit error     at async Map.[getReport] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/audit-report.js:335:21)
npm verb audit error     at async Map.run (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/audit-report.js:106:19) {
npm verb audit error   headers: [Object: null prototype] {
npm verb audit error     date: [ 'Mon, 17 Oct 2022 11:04:28 GMT' ],
npm verb audit error     server: [ 'Nexus/3.30.0-01 (OSS)' ],
npm verb audit error     'x-content-type-options': [ 'nosniff' ],
npm verb audit error     'content-security-policy': [
npm verb audit error       'sandbox allow-forms allow-modals allow-popups allow-presentation allow-scripts allow-top-navigation'
npm verb audit error     ],
npm verb audit error     'x-xss-protection': [ '1; mode=block' ],
npm verb audit error     'content-type': [ 'application/json' ],
npm verb audit error     'content-length': [ '228' ],
npm verb audit error     'x-fetch-attempts': [ '1' ]
npm verb audit error   },
npm verb audit error   statusCode: 400,
npm verb audit error   code: 'E400',
npm verb audit error   method: 'POST',
npm verb audit error   uri: 'http://153.89.23.53:8082/repository/npm-all/-/npm/v1/security/audits/quick',
npm verb audit error   body: <Buffer 0a 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ... 178 more bytes>,
npm verb audit error   pkgid: 'quick'
npm verb audit error }
npm timing auditReport:getReport Completed in 1449ms
npm timing reify:audit Completed in 1452ms
npm verb stack Error: write EPIPE
npm verb stack     at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:94:16)
npm verb cwd /builds/Xperthis-UX/care_frontend_ux
npm verb Linux 3.10.0-1160.49.1.el7.x86_64
npm verb node v16.18.0
npm verb npm  v8.19.2
npm ERR! code EPIPE
npm ERR! syscall write
npm ERR! errno -32
npm ERR! write EPIPE
npm verb exit -32
npm timing npm Completed in 5033ms

I first managed to fix the problem ONCE by switching from a basic alpine image to the node:16-alpine. But the build broke once again the next day. And now, I'm out of ideas...

ALansmanne
  • 271
  • 1
  • 6
  • 17
  • 2
    `EPIPE` means that something is writing to a pipe that's already quit reading (e.g., `yes | exit` will do it since `yes` writes forever and `exit` just exits). As this is happening while npm is running, it's not a Git issue, it's a GitLab CI plus npm issue, and ideally you should examine the debug log if it's available somewhere. If not, get your `npm ci` to run more verbosely so you can see what command is quitting without reading some piped output. – torek Oct 17 '22 at 09:40
  • 1
    Ok, I've added --verbose to get more information, and edited the main post. I do see a strange error on a POST request to our internal registry, but I'm not sure if that's just a side effect, the cause, or something unrelated. – ALansmanne Oct 17 '22 at 11:07
  • 2
    Ok, this error seems to be the cause... as the build continues when adding "--no-audit" to npm ci. I am confused now... – ALansmanne Oct 17 '22 at 11:40
  • 1
    Just wanted to confirm that we ran exactly into the same issue and "--no-audit" fixed it for us, too. Might be related to internal registries as we also use one. – okirmis Oct 20 '22 at 08:26

1 Answers1

3

I just had the same problem when running "npm install" with my Gitlab-Ci pipeline today.

It seems something changed in the node version 16.18 (currently node:latest on docker hub).

Instead of using node:latest in my pipeline I set it back to fixed version: node:16.17.1-buster Pipeline runs again after that.

Steffen
  • 51
  • 3
  • 2
    Solved my issue. Also works with `npm ci --no-audit` instead. Both not ideal from security perspective. – ggradnig Nov 16 '22 at 17:33