Repository navigation
fix(h5p-verify): exit once the report is written (#117) - #119
Merged
Merged
Conversation
The command printed the report and called process.exit straight after. Node writes to a pipe asynchronously on macOS, and process.exit drops what is still waiting, so a program reading --json through a pipe got the first 8,192 bytes and JSON that did not parse. It now exits from the write's callback, or when the reader has gone away. 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 #117.
What
bin/h5p-verify.mjsprinted the report withconsole.logand calledprocess.exitstraight after. On macOS Node writes to a pipe asynchronously, andprocess.exitdrops whatever is still waiting. So a program reading--jsonthrough a pipe got the first 8,192 bytes, and the JSON did not parse. The command now writes the report, or the summary, and exits from the write's callback, with the same exit code as before. It also exits if the reader has gone away, asheaddoes.Checked
verify.test.ts: it runs the command throughexecFile, as a program would, on a quiz with 300 fields the semantics do not name. Played untrusted, each removed field is reported, so the report runs to tens of kilobytes. The test checks that stdout is over 16 kB and parses to the same report asreport.json. Without the fix it fails on macOS with "expected 8192 to be greater than 16384". CI's Linux runners may not catch a regression, since a Linux pipe takes 64 kB at once.head -c 100exits 0 with nothing on stderr.process.exitCodeand does not callprocess.exitafter printing, so it is not affected.process.exitafter its summary. But it writes each entry's line while it works, so only the short summary comes just before the exit. A dry run ofboardgame.h5p, 16,167 bytes of output, arrived whole throughexecFilein 3 runs of 3. It is left as it is.🤖 Generated with Claude Code