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

pnpm exits with code 0 when child node process OOMs #5525

Closed
pclalv opened this issue Oct 19, 2022 · 2 comments · Fixed by pnpm/npm-lifecycle#39
Closed

pnpm exits with code 0 when child node process OOMs #5525

pclalv opened this issue Oct 19, 2022 · 2 comments · Fixed by pnpm/npm-lifecycle#39
Milestone

Comments

@pclalv
Copy link

pclalv commented Oct 19, 2022

pnpm version: 7.13.5

Code to reproduce the issue:

  1. clone https://github.com/pclalv/pnpm-oom-exit-code-swallowed .
  2. install the required versions of NodeJS and pnpm.
  3. run the code in ./repro.sh (in my experience, whether you run the
    pnpm command directly in your shell, or whether you run
    ./repro.sh, the result should be the same) and observe that the
    exit code is 0.

Expected behavior:

I expected the exit code to be non-zero, given:

  • that the child node process OOMed; and
  • that the exit code is non-zero when the code is run with node
    (NODE_OPTIONS=--max-old-space-size=32 node ./oom.js) or npm (npm run bash -- -c 'NODE_OPTIONS=--max-old-space-size=32 node ./oom.js').

Actual behavior:

pnpm exits with code 0.

this 'false positive' exit code can cause problems in automation, for example,
by allowing a process to continue when it should have been aborted by the OOM.

Additional information:

  • node -v prints: v18.11.0
  • Windows, macOS, or Linux?: macOS
@P0ppoff
Copy link

P0ppoff commented Nov 22, 2022

I have the same error on my ci runner. Runner's memory is limited to 500Mo, too short for vitest which crashes:

<--- Last few GCs --->
[1149:0x5242560]    41650 ms: Scavenge 507.5 (518.6) -> 506.9 (519.4) MB, 3.8 / 0.0 ms  (average mu = 0.311, current mu = 0.288) allocation failure; 
[1149:0x5242560]    41656 ms: Scavenge 508.0 (519.4) -> 507.5 (520.4) MB, 3.9 / 0.0 ms  (average mu = 0.311, current mu = 0.288) allocation failure; 
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0xb6e500 node::Abort() [node]
 2: 0xa7e632  [node]
 3: 0xd47f20 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
 4: 0xd482c7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
 5: 0xf25685  [node]
 6: 0xf26588 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]
 7: 0xf36a93  [node]
 8: 0xf37908 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
 9: 0xf3aad5 v8::internal::Heap::HandleGCRequest() [node]
10: 0xeb8c2f v8::internal::StackGuard::HandleInterrupts() [node]
11: 0x12b782f v8::internal::Runtime_StackGuardWithGap(int, unsigned long*, v8::internal::Isolate*) [node]
12: 0x16e99f9  [node]

But PNPM command exits with a 0.

@await-ovo
Copy link
Member

await-ovo commented Nov 30, 2022

The exit code of out-of-memory child process will be null, and the singal will be SIGABRT.

It seems that @pnpm/npm-lifecycle run script only throw an error when exit code exists currently, this results in a out-of-memory or press Ctrl + C to end the process, the final exit code of pnpm is 0

https://github.com/pnpm/npm-lifecycle/blob/main/index.js#L279

zkochan pushed a commit to pnpm/npm-lifecycle that referenced this issue Nov 30, 2022
close pnpm/pnpm#5525
Co-authored-by: Zoltan Kochan <z@kochan.io>
@zkochan zkochan added this to the v7.18 milestone Dec 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants