Skip to content

fix(verify): a Ctrl+C through npx ends the preview with its closing line and exit code 0 - #80

Merged
alekswebnet merged 1 commit into
mainfrom
fix/verify-preview-signals
Oct 23, 2026
Merged

alekswebnet merged 1 commit into
mainfrom
fix/verify-preview-signals

Conversation

@alekswebnet

Copy link
Copy Markdown
Contributor

Closes #79.

Run through npx, as the docs and both skills run it, h5p-verify --preview ended on Ctrl+C without its closing line, and never exited with the 0 the README and docs/compatibility.md promise. Through npx, one Ctrl+C reaches the command twice:

  1. the terminal sends SIGINT to the whole process group;
  2. npm passes on the SIGINT it received.

The command listened with process.once. The second signal found no listener, took Node's default action, and killed the process. The preview itself still stopped and freed its port.

Changes

  • bin/h5p-verify.mjs: the SIGINT and SIGTERM listeners stay for the life of the process (process.on). Ending the preview a second time already did nothing.
  • The listeners go in before anything is printed. Installed after the closing instructions, as before, a Ctrl+C the moment the address appeared could still find no listener. The new test hit that once under the full suite's load.
  • tests/preview.test.ts: a test runs the command behind a stand-in for npm, which passes signals on, in a process group of its own. It sends the group one SIGINT, as a terminal does, and expects the closing line and exit code 0. Skipped on Windows, which has no process groups to signal.
  • AGENTS.md: the preview's entry records why the listeners are installed early and kept.

Testing

One SIGINT to the process group each run:

Verifier How it ran Runs Closing line Exit
1.2.0 as published through npx 3 never killed by SIGINT
this branch, packed with pnpm pack through npx --package 3 every time 0
1.2.0 as published behind the npm stand-in 10 never killed by SIGINT
1.2.0 as published alone 5 every time 0
  • The new test: failed 3 times of 3 on the old code; passed 5 of 5 alone on this branch.
  • The verifier's suite: 23 of 23, three runs in a row, and typecheck passes.

Release

A patch for @missing-elements/h5p-verify: 1.2.1. Nothing else changes.

🤖 Generated with Claude Code

…ine and exit code 0

Through npx one Ctrl+C reaches the preview twice: the terminal sends SIGINT to the whole process
group, and npm passes on the one it got. The command listened with process.once, so the second
signal found no listener, took Node's default and killed the process before "The preview ended.",
and it never exited with the 0 the README and docs/compatibility.md promise.

The SIGINT and SIGTERM listeners now stay for the life of the process, and go in before anything
is printed, so a signal as soon as the address shows finds them too. Ending the preview twice was
already harmless. A test runs the command behind a stand-in for npm, in a process group of its
own, and sends the group one SIGINT: it failed 3 times of 3 on the old code, and passes.

Closes #79.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alekswebnet
alekswebnet merged commit 3809044 into main Oct 23, 2026
7 checks passed
@alekswebnet
alekswebnet deleted the fix/verify-preview-signals branch October 27, 2026 20:03
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.

h5p-verify --preview: through npx, Ctrl+C kills the preview before its closing line, and it does not exit with 0

1 participant