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 makes the child processes orphan on EACCES #7053

Open
2 tasks done
moznion opened this issue Dec 1, 2023 · 0 comments
Open
2 tasks done

[BUG] npm makes the child processes orphan on EACCES #7053

moznion opened this issue Dec 1, 2023 · 0 comments
Assignees
Labels
Bug thing that needs fixing Priority 1 high priority issue

Comments

@moznion
Copy link

moznion commented Dec 1, 2023

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 the npm CLI encounters an EACCES error due to a permissions issue, as shown below,

npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /tmp/foo/bar/_cacache/tmp
npm ERR! errno -13
npm ERR!
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR!
npm ERR! To permanently fix this problem, please run:
npm ERR!   sudo chown -R 1000:1000 "/tmp/foo/bar"

npm ERR! Log files were not written due to an error writing to the directory: /tmp/foo/bar/_logs
npm ERR! You can rerun the command with `--loglevel=verbose` to see the logs in your terminal

the process invoked by npm becomes an orphan.

For instance, if npm start launches a daemon program, like an Express app, and npm terminates due to the same error, the npm process will exit with status 243, but the daemon program remains active.

The process tree initially looks like this:

1708440 pts/7    Ss     0:00 -bash
1714893 pts/7    Sl+    0:00  \_ npm start
1714922 pts/7    S+     0:00      \_ sh -c node --expose-gc app
1714923 pts/7    Rl+    0:00          \_ node --expose-gc app

becomes

1714922 pts/7    S      0:00 sh -c node --expose-gc app
1714923 pts/7    Rl     0:00  \_ node --expose-gc app
Screencast.from.12-01-2023.02_32_38.AM.mp4

Is this behavior intentional?

Expected Behavior

The invoked process by npm dies as well.

Steps To Reproduce

  1. Run npm with an inaccessible cache directory, for example, by using the nobody user or specifying an inaccessible directory for the cache parameter in .npmrc.
  2. Execute npm-related tasks.

I have created an example repository to facilitate easier reproduction. The Dockerfile outlines the environment and sets up a reproducible playground.

https://github.com/moznion/npm-orphan-example

Environment

  • npm: 10.2.4
  • Node.js: v20.10.0
  • OS Name: Linux 868d0296baea 6.2.0-37-generic #38~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov 2 18:01:13 UTC 2 x86_64 GNU/Linux
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
  • System Model Name: n/a
  • npm config:
; "user" config from /home/user/.npmrc

cache = "/tmp/inaccessible/.npm"

; node bin location = /usr/local/bin/node
; node version = v20.10.0
; npm local prefix = /home/user/npm-orphan-example
; npm version = 10.2.4
; cwd = /home/user/npm-orphan-example
; HOME = /home/user
; Run `npm config ls -l` to show all defaults.
@moznion moznion added Bug thing that needs fixing Needs Triage needs review for next steps Release 10.x labels Dec 1, 2023
@moznion moznion changed the title [BUG] npm makes the child processes orphan [BUG] npm makes the child processes orphan on EACCES Dec 1, 2023
@wraithgar wraithgar added Priority 1 high priority issue and removed Needs Triage needs review for next steps labels Dec 4, 2023
@lukekarrys lukekarrys self-assigned this May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 1 high priority issue
Projects
None yet
Development

No branches or pull requests

3 participants