fix: read replay stdin asynchronously so pipes work - #33
Merged
Conversation
`aas export <id> | aas replay -` failed with EAGAIN: readFileSync(0) does not reliably drain a pipe on all platforms. Read piped stdin asynchronously in chunks with the existing size cap and empty-document rejection preserved. TTY use still fails closed with the usage hint.
| chunks.push(typeof chunk === "string" ? Buffer.from(chunk, "utf8") : chunk); | ||
| } | ||
| const text = Buffer.concat(chunks).toString("utf8"); | ||
| if (text.length > CHILD_JSON_LIMIT) { |
There was a problem hiding this comment.
🟡 Multibyte bundles bypass byte limit
Valid JSON with multibyte text can exceed CHILD_JSON_LIMIT bytes while passing the character-count check. Replay then accepts an oversized bundle.
Suggested change
| if (text.length > CHILD_JSON_LIMIT) { | |
| if (Buffer.byteLength(text, "utf8") > CHILD_JSON_LIMIT) { |
Was this helpful? React with 👍 or 👎 to provide feedback.
Comment on lines
+1447
to
+1452
| const chunks = []; | ||
| for await (const chunk of stdin) { | ||
| chunks.push(typeof chunk === "string" ? Buffer.from(chunk, "utf8") : chunk); | ||
| } | ||
| const text = Buffer.concat(chunks).toString("utf8"); | ||
| if (text.length > CHILD_JSON_LIMIT) { |
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.
Defect
The documented
aas export <run-id> | aas replay -pipeline was broken:readFileSync(0)raisedEAGAIN: resource temporarily unavailable, readinstead of consuming piped bundle JSON. Reproduced live before the fix;
the file-input path was unaffected.
Fix
Read piped stdin asynchronously in chunks. The size cap, empty-document
rejection, and TTY usage error are unchanged. Verified live: piped
export-to-replay of a rail-review run now verifies end to end, exit 0.
Tests
(exit 2), and oversized piped input fails closed against the byte
limit.
npm test: 73/73.