Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] npm exit status should be indicative of the error #7109

Closed
2 tasks done
balupton opened this issue Dec 29, 2023 · 3 comments
Closed
2 tasks done

[BUG] npm exit status should be indicative of the error #7109

balupton opened this issue Dec 29, 2023 · 3 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 10.x

Comments

@balupton
Copy link

balupton commented Dec 29, 2023

Is there an existing issue for this?

  • I have searched the existing issues

The only related issue I could find was #4724 however that is adjacent to this.

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

I maintain a GitHub action that publishes to npm, which occasionally encounters the error:

npm ERR! code E409
npm ERR! 409 Conflict - PUT https://registry.npmjs.org/get-cli-arg - Failed to save packument. A common cause is if you try to publish a new package before the previous package has been fully processed.

npm ERR! A complete log of this run can be found in: /home/runner/.npm/_logs/2023-12-29T16_27_48_507Z-debug-0.log
npm publish failed with exit status: 1

from the following code:

https://github.com/bevry-actions/npm/blob/3d7f43852ed3893954dfe3e788c17af03c08c404/action.bash#L50-L73

We can see that the error code is 409, however unfortunately to get this information programatically I would have to scan stderr. I believe instead of scanning stderr, npm should make the exit status the error code, in this case 409, instead of just returning exit status 1.

I understand this is more of a feature request, however there wasn't a template for that when creating this issue.

Expected Behavior

Exit status for error code 409 should be 409 instead of 1, to allow easy programatic identification (exit status are readily available via most programming languages that deal with CLI execution) whereas stderr scanning is more tedious.

Steps To Reproduce

To reproduce error 409, publish two updates to a package in quick succession, such as a preview release tag and a latest release.

Environment

  • npm: 10.2.3
  • Node.js: v20.10.0
  • OS Name: Ubuntu 22.04.3 LTS
  • System Model Name: I believe x86_64, but not relevant
  • npm config: not relevant
@balupton balupton added Bug thing that needs fixing Needs Triage needs review for next steps Release 10.x labels Dec 29, 2023
balupton added a commit to bevry-actions/npm that referenced this issue Dec 29, 2023
@balupton balupton changed the title [BUG] npm exit status is indicative of the error [BUG] npm exit status should be indicative of the error Jan 11, 2024
@wraithgar
Copy link
Member

That is not how exit codes work in linux et al. There are a few predefined linux exit codes already https://www.man7.org/linux/man-pages/man3/sysexits.h.3head.html. They are not the same as the windows exit codes https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-

Folks who need to log in should not have npm telling Windows that there is a ERROR_THREAD_MODE_NOT_BACKGROUND error.

@wraithgar wraithgar closed this as not planned Won't fix, can't repro, duplicate, stale Jan 12, 2024
@wraithgar
Copy link
Member

Most cross-platorm apps stick to 1, 0, and -1 for exit codes for just this reason.

@balupton
Copy link
Author

balupton commented Jan 12, 2024

I'm sorry, but those links refer to exit statuses from linux system processes and error codes from windows system function calls. There is no requirement nor stated expectation that non-system programs ought to or are expected to return the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 10.x
Projects
None yet
Development

No branches or pull requests

2 participants