mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-18 22:24:17 +01:00
gstack's script runner and merge-queue checks now refuse cut-off command output (GST-3104) (#4502)
The helper that runs gstack's own scripts and `bash -c` commands, and the merge queue's branch-ownership, stacked-test, release-version and merge-group record checks, now fail with `SPAWN_OUTPUT_INCOMPLETE` when Bun cuts a command's output off, instead of treating part of it as the whole answer. Why: #4492 added this for the scanners and gates but left these on Node's `spawnSync`, and its release note claimed wider coverage than it shipped. Nothing to do: a new test stops any new gstack command from calling Node's `spawnSync` directly. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
d789dd965b
commit
2f57b07495
14 files changed
+237
-11
No files matched your search
@@ -226,3 +226,31 @@ describe('wtreeFingerprint', () => {
|
||||
} finally { fs.rmSync(dir, { recursive: true, force: true }); fs.rmSync(shim, { recursive: true, force: true }); }
|
||||
});
|
||||
});
|
||||
|
||||
describe('runScriptSync and runBashSync with output past maxBuffer (GST-3104)', () => {
|
||||
// A child that ignores SIGTERM outlives Bun's overflow kill and exits 0, so raw spawnSync would
|
||||
// report status 0 with ENOBUFS and cut-off stdout (GST-3086); these runners must report status null.
|
||||
const OVERFLOW = "process.on('SIGTERM', () => {}); process.stdout.write('x'.repeat(200000)); setTimeout(() => {}, 300);";
|
||||
const expectIncomplete = (r: { status: number | null; error?: Error; stderr: string }) => {
|
||||
expect(r.status).toBeNull();
|
||||
expect((r.error as NodeJS.ErrnoException | undefined)?.code).toBe('ENOBUFS');
|
||||
expect(r.stderr.trimEnd().split('\n').pop() ?? '').toEndWith('(SPAWN_OUTPUT_INCOMPLETE)');
|
||||
};
|
||||
|
||||
test('a bun-shebang script that overflows and exits 0 is not a finished read', () => {
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'script-invocation-overflow-'));
|
||||
try {
|
||||
const script = path.join(dir, 'gstack-overflow');
|
||||
fs.writeFileSync(script, `#!/usr/bin/env bun\n${OVERFLOW}\n`, { mode: 0o755 });
|
||||
expectIncomplete(runScriptSync(script, [], { encoding: 'utf8', maxBuffer: 1024, timeout: 20_000 }));
|
||||
} finally {
|
||||
fs.rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
// POSIX only: the command needs a POSIX bash with trap and /dev/zero.
|
||||
test.skipIf(process.platform === 'win32')('a bash -c string that overflows and exits 0 is not a finished read', () => {
|
||||
expectIncomplete(runBashSync("trap '' TERM; head -c 200000 /dev/zero | tr '\\0' x; sleep 0.3; exit 0", { encoding: 'utf8', maxBuffer: 1024, timeout: 20_000 }));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user