Skip to content

Commit 1976ace

Browse files
committed
test(gateway): fix ETXTBSY flake in workspace-sync candidate bounding
The test rewrote its mock git script between two createGitTransferList calls. On Linux CI the second spawn can race a lingering fork of the first child still holding the script's write fd, failing exec with ETXTBSY. Write the script once; vary the entry count through a data file the script reads instead.
1 parent e78ab28 commit 1976ace

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

‎src/gateway/worker-environments/workspace-sync-local.test.ts‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,19 +268,26 @@ describe("runLocalCommandToFile", () => {
268268
const root = tempDirs.make("openclaw-workspace-candidates-");
269269
const bin = path.join(root, "bin");
270270
const mockGit = path.join(bin, "git");
271+
const countFile = path.join(bin, "git-entry-count");
271272
const firstTransfer = `${root}-transfer-accepted`;
272273
const secondTransfer = `${root}-transfer-rejected`;
274+
// Rewriting an executed script between spawns races exec against a forked
275+
// child still holding the write fd (ETXTBSY). Write the script once and
276+
// vary only a data file it reads.
273277
const writeMockGit = async (count: number) => {
278+
await fs.writeFile(countFile, String(count));
279+
};
280+
try {
281+
await fs.mkdir(bin);
274282
await fs.writeFile(
275283
mockGit,
276284
`#!/usr/bin/env node
277-
process.stdout.write("eligible.txt\\0".repeat(${count}));
285+
const fs = require("node:fs");
286+
const count = Number(fs.readFileSync(${JSON.stringify(countFile)}, "utf8"));
287+
process.stdout.write("eligible.txt\\0".repeat(count));
278288
`,
279289
{ mode: 0o755 },
280290
);
281-
};
282-
try {
283-
await fs.mkdir(bin);
284291
await fs.writeFile(path.join(root, "eligible.txt"), "eligible\n");
285292
vi.stubEnv("PATH", `${bin}${path.delimiter}${process.env.PATH ?? ""}`);
286293
await writeMockGit(MAX_WORKSPACE_INVENTORY_ENTRIES + 1);

0 commit comments

Comments
 (0)