npm / cli

the package manager for JavaScript
https://docs.npmjs.com/cli/
Other
8.33k stars 3.06k forks source link

[BUG] npm error Exit handler never called exits with status code 0 #7672

Closed Sebastian-Webster closed 1 month ago

Sebastian-Webster commented 1 month ago

Is there an existing issue for this?

This issue exists in the latest npm version

Current Behavior

This issue, related to #7666 and #7669, exits with status code 0 when the exit handler npm error occurs. Exiting with status code 0 allows the ci to continue to the next steps.

Expected Behavior

I would expect it to exit with status code 1 since it is an error. That way ci would fail when this error occurs.

Steps To Reproduce

The GitHub Actions workflow showing this behaviour can be found at: https://github.com/Sebastian-Webster/npm-reproducible-example/actions/runs/10007253675 The repository code for that workflow can be found here at: https://github.com/Sebastian-Webster/npm-reproducible-example/tree/22.5.0 This example shows that the issue does not happen in Node 22.4.1, but does in 22.5.0.

Environment

RedYetiDev commented 1 month ago

Resolved in Node.js v22.5.1. See #7667 and https://github.com/nodejs/node/issues/53902.

AmalendhuKR commented 1 month ago

Dockerization is failing with 'react-scripts' not found error. It took me some more time to figure out FROM node was the cause of the error. Taking the latest cannot go all the time! Took the image of node LTS FROM node:20.15.1

wraithgar commented 1 month ago

This is fixed in the latest version of Node.js. See https://github.com/npm/cli/issues/7657 and https://github.com/nodejs/node/issues/53902 for more info

wraithgar commented 1 month ago

Didn't see that this had to do w/ the exit code. Yes, the underlying problem causing the early exit was fixed. The fact that npm does not exit w/ status code 1 is a separate problem.

gabriel-piltzer-trimble commented 1 month ago

Why when my GitHub workflow step is configured like this, does it still use the broken 22.5.0 instead of 22.5.1?

      - name: Set up Node.js
        uses: actions/setup-node@v2
        with:
          node-version: '22'

Logs

Run actions/setup-node@v2
##[debug]isExplicit: 
##[debug]explicit? false
##[debug]isExplicit: 16.20.2
##[debug]explicit? true
##[debug]isExplicit: 18.20.4
##[debug]explicit? true
##[debug]isExplicit: 20.15.1
##[debug]explicit? true
##[debug]evaluating 3 versions
##[debug]match not found
Attempting to download 22...
##[debug]No manifest cached
##[debug]Getting manifest from actions/node-versions@main
##[debug]set auth
##[debug]check 22.5.0 satisfies 22
##[debug]arm64===x64 && darwin===linux
##[debug]x64===x64 && darwin===linux
##[debug]arm64===x64 && linux===linux
##[debug]x64===x64 && linux===linux
##[debug]matched 22.5.0
Acquiring 22.5.0 - x64 from https://github.com/actions/node-versions/releases/download/22.5.0-998514[41](https://github.com/Trimble-Construction/prism-ui-common/actions/runs/9994900258/job/27670890096#step:3:42)03/node-22.5.0-linux-x64.tar.gz
##[debug]Downloading https://github.com/actions/node-versions/releases/download/22.5.0-99851[44](https://github.com/Trimble-Construction/prism-ui-common/actions/runs/9994900258/job/27670890096#step:3:45)103/node-22.5.0-linux-x64.tar.gz
Sebastian-Webster commented 1 month ago

Hi @gabriel-piltzer-trimble, I am experiencing that same problem too. The node-versions list has not been updated yet and so 22.5.1 is not yet available in GitHub Actions. Once this pull request gets merged: https://github.com/actions/node-versions/pull/182, 22.5.1 will be available on GitHub Actions.

danielhjacobs commented 1 month ago

@gabriel-piltzer-trimble As an aside, you should use actions/setup-node@v4, not actions/setup-node@v2.