From 8378f6caa9f927b9ab38ee023d944b2991787f66 Mon Sep 17 00:00:00 2001 From: Shoubhit Dash Date: Mon, 14 Sep 2026 20:31:19 +0530 Subject: [PATCH] test(core): avoid stdin race in check-ignore flake test (#48995) --- packages/core/test/git.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/core/test/git.test.ts b/packages/core/test/git.test.ts index a5fcdeef408..39702b62d33 100644 --- a/packages/core/test/git.test.ts +++ b/packages/core/test/git.test.ts @@ -135,8 +135,10 @@ describe("Git trees", () => { await Promise.all(paths.map((file) => Bun.write(path.join(project, file), "two\n"))) await Bun.write(path.join(source.gitDirectory, "info", "exclude"), exitCode === 0 ? `${paths[1]}\n` : "") if (exitCode === 128) await Bun.write(path.join(source.gitDirectory, "config"), "[broken\n") + // A broken config makes git exit before reading stdin, so piping a Buffer races an EPIPE on the writer. + const stdin = exitCode === 128 ? Bun.file("/dev/null") : Buffer.from(paths.join("\0") + "\0") const result = - await $`git --git-dir ${source.gitDirectory} --work-tree ${source.worktree} check-ignore --no-index --stdin -z < ${Buffer.from(paths.join("\0") + "\0")}` + await $`git --git-dir ${source.gitDirectory} --work-tree ${source.worktree} check-ignore --no-index --stdin -z < ${stdin}` .cwd(project) .quiet() .nothrow()