Skip to content

"Exit handler never called" error when /proc is not accessible  #6316

@codedokode

Description

@codedokode

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

When /proc/stat and /proc/cpuinfo are not accessible and version 1 package-lock.json is present, npm ci fails to install packages with "exit handler never called" error after "The package-lock.json file was created with an old version of npm" warning. This is caused by a bug in promise-call-limit library.

To check whether the system is affected by the bug one can run this command:

node -e "console.log(require('os').cpus())"

If it prints an empty list [] then there is a bug and npm will fail either at idealTree:inflate stage or at build:run:* stage. This is caused by a bug in callLimit function that doesn't run any of the passed functions if CPU count cannot be determined. This function is invoked in two places: when parsing old lock file and when running build:run.

I have made a pull request to fix the bug: isaacs/promise-call-limit#11 . Please consider updating promise-call-limit version.

So, the bug only happens if /proc not being accessible and stage is idealTree:inflate (and old lockfile is present) or build:run:*.

Searching around shows that there are bugs from users trying to use npm in different OSes which might be caused by the same reason:

These users should run the command above to check whether their issue is caused by this bug.

Expected Behavior

npm ci runs successfully without errors

Steps To Reproduce

  1. Create a container without /proc mounted or unmount /proc or use OS without /proc
  2. Run node -e "console.log(require('os').cpus())" and see that it prints []
  3. Create a directory and create a package-lock.json with following contents:
{
  "name": "test-npm-bug",
  "requires": true,
  "lockfileVersion": 1,
  "dependencies": {
    "@nodelib/fs.stat": {
      "version": "2.0.5",
      "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz",
      "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A=="
    }
  }
}

Also create package.json:

{
  "name": "test-npm-bug",
  "dependencies": {
      "@nodelib/fs.stat": "2.0.5"
  }
}
  1. Run npm ci --ddd
  2. See messages in log:
npm WARN old lockfile 
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile 
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile 
npm verb unfinished npm timer command:ci 1680276840213
npm verb unfinished npm timer idealTree 1680276840284
npm verb unfinished npm timer idealTree:inflate 1680276840288
npm info ok 
npm ERR! Exit handler never called!

Environment

  • npm: 9.6.3
  • Node.js: v18.15.0
  • OS Name: Linux
  • System Model Name:
  • npm config:
; node bin location = /usr/bin/node
; node version = v18.15.0
; npm local prefix = /shared/test-npm
; npm version = 9.6.3
; cwd = /shared/test-npm
; HOME = (removed)
; Run `npm config ls -l` to show all defaults.

Metadata

Metadata

Assignees

Labels

Priority 1high priority issueRelease 9.xwork is associated with a specific npm 9 release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions