FG
🛠️ Developer ToolsMicrosoft

[BUG] Exit handler never called during clean-install, with Node.js v22.5.0

Freshabout 21 hours ago
Mar 14, 20260 views
Confidence Score90%
90%

Problem

Is there an existing issue for this? - [X] I have searched the existing issues This issue exists in the latest npm version - [X] I am using the latest npm Current Behavior (While there are similar issues already open, the wiki page for "exit handler never called" errors recommends opening a new issue, so I am doing so) I am running into errors when using Node.js v22.5.0 and npm v10.8.2 to install dependencies. In GitHub Actions, I'm seeing an "Exit handler never called!" error. I tried installing the same versions locally, and instead npm never exits -- the packages get installed, but I just see a spinner in the terminal forever. I did not have any issues in CI prior to the release of Node.js v22.5.0. When I use Node.js v20.12.2 and npm v10.8.2 locally, installation completes successfully. Thus, I think some change in Node.js v22.5.0 must be related. Here's a log file from the error happening in GitHub Actions: 2024-07-17T17_07_43_972Z-debug-0.log. This came from the following run: https://github.com/divviup/divviup-api/actions/runs/9978466717/job/27575428716?pr=1178 Expected Behavior `npm ci` should succeed and exit cleanly. Steps To Reproduce 1. Install Node.js v22.5.0. 1. Install npm v10.8.2. 1. `git clone https://github.com/divviup/divviup-api.git` 1. `cd divviup-api/app` 1. `git checkout 3edafaefe90795387db3e35a161f3110c3ac3dea` 1. `npm ci` Environment - npm: v10.8.2 - Node.js: v22.5.0 - OS Name: Ubuntu - System Model Name: Unknown, Azure instance - npm conf

Error Output

error happening in GitHub Actions: [2024-07-17T17_07_43_972Z-debug-0.log](https://github.com/user-attachments/files/16271253/2024-07-17T17_07_43_972Z-debug-0.log). This came from the following run: https://

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix Exit Handler Issue in npm with Node.js v22.5.0

Medium Risk

The issue arises due to a change in the Node.js v22.5.0 event loop and process exit handling, which affects how npm manages its exit handlers during dependency installation. This leads to the 'Exit handler never called!' error and causes npm to hang indefinitely during `npm ci` operations.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Downgrade Node.js

    Switch to a stable version of Node.js that is known to work with npm v10.8.2. The recommended version is Node.js v20.12.2.

    bash
    nvm install 20.12.2 && nvm use 20.12.2
  2. 2

    Verify npm Version

    Ensure that you are using the correct version of npm that is compatible with the downgraded Node.js version.

    bash
    npm -v
  3. 3

    Clear npm Cache

    Clear the npm cache to avoid any potential issues caused by cached packages that may have been corrupted during previous installations.

    bash
    npm cache clean --force
  4. 4

    Reinstall Dependencies

    Run `npm ci` to reinstall the dependencies in a clean state after ensuring the environment is set up correctly.

    bash
    npm ci
  5. 5

    Test the Installation

    Confirm that the installation completes successfully without hanging or errors. Monitor the output for any issues.

    bash
    echo 'Installation successful!'

Validation

To confirm the fix worked, ensure that `npm ci` completes without hanging and exits cleanly. Check the exit status with `echo $?` to verify it returns 0, indicating success.

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

npmpackage-managernodejsbugneeds-triage