Repository navigation
fix(verify): a Ctrl+C through npx ends the preview with its closing line and exit code 0 - #80
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #79.
Run through npx, as the docs and both skills run it,
h5p-verify --previewended on Ctrl+C without its closing line, and never exited with the 0 the README anddocs/compatibility.mdpromise. Through npx, one Ctrl+C reaches the command twice: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.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.Testing
One SIGINT to the process group each run:
npxpnpm packnpx --packagetypecheckpasses.Release
A patch for
@missing-elements/h5p-verify: 1.2.1. Nothing else changes.🤖 Generated with Claude Code