Repository navigation
test(engine-spawn-cmd): publish the fake claude's argv dump atomically - #145
Merged
Merged
Conversation
The fake claude wrote its argv with `> dump`, which creates the file before the first byte lands, while the test polled only for the file to exist and then read it. Under load that read a truncated 40 KB argument and failed 'child received the 40 KB prompt byte-identical'. Write to <dump>.tmp in the same directory and mv it into place, so the dump exists only once it is complete. No assertion changed.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
Problem
test/engine-spawn-cmd.test.jswas flaky under load (about 1 run in 3 failed withFAIL child received the 40 KB prompt byte-identical).The fake
claudewrote its argv one argument at a time withfor a in "$@"; do printf '%s\0' "$a"; done > dump. The shell createsdumpwhen it opens the redirect, before any byte is written, while the test polls only for the file to exist and then reads it immediately. A slow writer therefore hands the test a truncated argv.Fix (test only)
The fake writes to
<dump>.tmpin the same directory andmvs it to<dump>once the loop finishes. A same-directory rename is atomic, so the dump exists only when complete. No assertion changed, and no production file is touched.Proof
A throwaway local edit (not committed) added
sleep 0.2after eachprintfplus a log of what was read:PROOF read 1 args, 12 B of argv at read time, then 4 FAILs including the 40 KB prompt check (17 passed, 4 failed)PROOF read 9 args, 40182 B of argv at read time(21 passed, 0 failed)Unmodified test with the fix, 5 serial runs on tmux 3.8:
21 passed, 0 failedeach time.