The spawnSync overflow test no longer fails about once an hour on CI (GSTA-712) (#4613)

The raw-Bun overflow test in test/spawn-sync.test.ts stops failing at
random on CI: its child process now writes 32 KiB instead of 200,000
bytes.

Why: the old write sat 13 KB under Linux's 212,992-byte socket send
buffer. When it didn't fit, the child hit a broken pipe and exited 1, so
the test saw status 1 instead of 0. Trunk flagged it 22 times in one
day, and every time it passed on retry.

Nothing to do: this changes tests only.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
Garry Tanandcapy-ai[bot] authored and GitHub committed 2026-11-21 14:46:51 +00:00
1 parent 27e5db9902
commit 43c9c201e3
3 files changed
+9 -3

No files matched your search

@@ -0,0 +1 @@
- **A flaky free test is fixed: the spawnSync overflow check no longer fails about once an hour on CI.** Its child process wrote 200,000 bytes, just under Linux's 212,992-byte socket send buffer. When the write didn't fit, the child hit a broken pipe and exited 1 instead of 0. The child now writes 32 KiB, which is still far past the test's 1 KiB output limit. This changes tests only.
+2 -1
View File
@@ -230,7 +230,8 @@ describe('wtreeFingerprint', () => {
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);";
// The write fits the Unix socket send buffer, so the child really exits 0 (see test/spawn-sync.test.ts).
const OVERFLOW = "process.on('SIGTERM', () => {}); process.stdout.write('x'.repeat(32768)); 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');
+6 -2
View File
@@ -3,7 +3,11 @@
* reads as a finished command. Bun can return status 0 together with error
* ENOBUFS and cut-off stdout when the child exits before the overflow kill
* lands (GSTA-618, seen on Bun 1.4.2 and 1.4.4). A child that ignores SIGTERM
* reproduces that every time, so these tests do not depend on timing.
* reproduces that every time, so these tests do not depend on timing, as long as
* its one write fits the Unix socket send buffer (212,992 bytes on Linux): a write
* that does not fit takes EPIPE when Bun closes its end, and the child exits 1
* within about 10 ms. 200,000 bytes sat 13 KB under that buffer and flaked on CI
* (GSTA-712), so the child writes 32 KiB, still far past maxBuffer.
*/
import { describe, expect, test } from 'bun:test';
import { spawnSync as rawSpawnSync } from 'node:child_process';
@@ -26,7 +30,7 @@ function realGit(env: NodeJS.ProcessEnv = process.env): string {
return Bun.which('git', { PATH: env.PATH }) || '/usr/bin/git';
}
const OVERFLOW = "process.on('SIGTERM', () => {}); process.stdout.write('x'.repeat(200000)); setTimeout(() => {}, 300);";
const OVERFLOW = "process.on('SIGTERM', () => {}); process.stdout.write('x'.repeat(32768)); setTimeout(() => {}, 300);";
const overflowArgs = ['-e', OVERFLOW];
describe('spawnSync (lib/spawn-sync.ts)', () => {