From eb90b5ad0e036b2a1ab53c05c38f6058b09beb4f Mon Sep 17 00:00:00 2001 From: Lexus2016 Date: Mon, 16 Nov 2026 09:18:22 +0100 Subject: [PATCH] test(engine-spawn-cmd): publish the fake claude's argv dump atomically 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 .tmp in the same directory and mv it into place, so the dump exists only once it is complete. No assertion changed. --- test/engine-spawn-cmd.test.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/engine-spawn-cmd.test.js b/test/engine-spawn-cmd.test.js index f33784a..f633d9b 100644 --- a/test/engine-spawn-cmd.test.js +++ b/test/engine-spawn-cmd.test.js @@ -83,9 +83,12 @@ const haveTmux = (() => { const r = spawnSync('tmux', ['-V'], { encoding: 'utf8' const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'ccs-96-')); const dump = path.join(dir, 'argv.bin'); // Fake `claude`: records its argv NUL-separated, then holds the pane open so the - // session is still there to assert on. + // session is still there to assert on. The argv is written to a temp file and + // renamed into place: `> dump` creates the file before the first byte lands, and + // the poll below reads as soon as the file EXISTS — under load that read a + // truncated 40 KB argument. A rename makes the dump appear only when complete. const fakeClaude = path.join(dir, 'claude'); - fs.writeFileSync(fakeClaude, '#!/bin/sh\nfor a in "$@"; do printf \'%s\\0\' "$a"; done > "' + dump + '"\nsleep 30\n', { mode: 0o755 }); + fs.writeFileSync(fakeClaude, '#!/bin/sh\nfor a in "$@"; do printf \'%s\\0\' "$a"; done > "' + dump + '.tmp" && mv "' + dump + '.tmp" "' + dump + '"\nsleep 30\n', { mode: 0o755 }); const realInner = buildInteractiveCommand({ claudeBin: fakeClaude, idFlag: "--session-id 'e2e'", modelAlias: 'sonnet', sp: BIG_PROMPT, mcpPath: null,