Skip to content

Commit 2f623c1

Browse files
Fix remove of tmp dir on github side
1 parent 8544afb commit 2f623c1

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

src/__tests__/CodexACPAgent/CodexAcpClient.test.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,27 @@ async function overrideCodexHome<T>(configToml: string, run: () => Promise<T>):
3030
} else {
3131
process.env[CODEX_HOME_ENV] = previousCodexHome;
3232
}
33-
fs.rmSync(codexHome, { recursive: true, force: true });
33+
await removeDirectoryWithRetry(codexHome);
34+
}
35+
}
36+
37+
async function removeDirectoryWithRetry(directory: string): Promise<void> {
38+
let lastError: NodeJS.ErrnoException | null = null;
39+
for (let attempt = 0; attempt < 5; attempt += 1) {
40+
try {
41+
fs.rmSync(directory, { recursive: true, force: true });
42+
return;
43+
} catch (error) {
44+
const err = error as NodeJS.ErrnoException;
45+
if (err.code !== "ENOTEMPTY" && err.code !== "EBUSY") {
46+
throw err;
47+
}
48+
lastError = err;
49+
await new Promise((resolve) => setTimeout(resolve, 50 * (attempt + 1)));
50+
}
51+
}
52+
if (lastError) {
53+
throw lastError;
3454
}
3555
}
3656

0 commit comments

Comments
 (0)