Skip to content

Misc signal cleanup #51

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

Merged
merged 1 commit into from
Aug 12, 2025
Merged

Misc signal cleanup #51

merged 1 commit into from
Aug 12, 2025

Conversation

isaacl
Copy link

@isaacl isaacl commented Aug 10, 2025

  • Fix test msg

  • Remove proc 'exit' handler during interrupt
    This code was a no-op as spawn.js does not emit exit events.
    This is actually good, because were it to be working, it would
    result in a race condition when a child exits non-zero:

    1. The lifecycle promise would be rejected, leading to log output
      and a possible pnpm exit
    2. This hook would force node to exit 0 immediately.
  • Fix the listener removals when child exits.

- Fix test msg
- Remove proc 'exit' handler during interrupt
  This code was a no-op as spawn.js does not emit `exit` events.
  This is actually good, because  were it to be working, it would
  result in a race condition when a child exits non-zero:
  1. The lifecycle promise would be rejected, leading to log output
     and a possible pnpm exit
  2. This hook would force node to exit 0 immediately.

- Fix the listener removals when child exits.
@zkochan zkochan merged commit 942123c into pnpm:main Aug 12, 2025
6 checks passed
isaacl added a commit to isaacl/npm-lifecycle that referenced this pull request Aug 16, 2025
This reverts the behavioral change from pnpm#41.

This change caused pnpm to improperly handle interactive
shell Ctrl-C, traping the received signal and also ignoring
the abnormal exit of the script. This often results still
in a quick exit (because the script has terminated), but
with exit code 0.

PR pnpm#41 behavior resulted in incorrect behavior, which also
diverges from npm (as well as `node --run`). As another problem,
it made pnpm internally inconsistent as Ctrl-C results in non-zero
in situations when lifecycles scripts are not actively running.
Even in the context of pnpm run, a very quick Ctrl-C, prior to
spawn, results in a non-zero pnpm exit.

For additional discussion see: pnpm#51

Fixes: pnpm/pnpm#9626
isaacl added a commit to isaacl/npm-lifecycle that referenced this pull request Aug 16, 2025
This reverts the behavioral change from pnpm#41.

This change caused pnpm to improperly handle interactive
shell Ctrl-C, trapping the received signal and also ignoring
the abnormal exit of the script. This often results still
in a quick exit (because the script has terminated), but
with exit code 0.

PR pnpm#41 resulted in incorrect behavior, which also diverges
from npm (as well as `node --run`). As another problem, it
made pnpm internally inconsistent as Ctrl-C results in non-zero
in situations when lifecycles scripts are not actively running.
Even in the context of pnpm run, a very quick Ctrl-C, prior to
spawn, results in a non-zero pnpm exit.

For additional discussion see: pnpm#51

Fixes: pnpm/pnpm#9626
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants