test(infra): retry recursive temp-dir removal instead of failing a shard on ENOTEMPTY (#11966)

Two shards on release/v3.8.51 went red in one day with the same signature —
"ENOTEMPTY, Directory not empty: /tmp/omniroute-<test>-XXXXXX" — from
combo-same-provider-cascade (Unit Tests fast-path 4/4, on a PR that touches only
.github/) and auth-policy-embeddings-webfetch-7785 (the 20k-test TIA step). Both pass
alone and on re-run: the cleanup races something still writing into the directory
(SQLite WAL/-shm checkpoint, a worker, the backup) and under a loaded hosted runner
the window opens. 1154 test files do their own cleanup with
fs.rmSync(dir, { recursive: true, force: true }); 57 already asked for retries.

One-shot codemod (scripts/ad-hoc/codemod-rm-maxretries.mjs, kept for the record):
every rm / rmSync / rmdirSync option object with `recursive: true` and no
`maxRetries` gains `maxRetries: 5, retryDelay: 100` — Node itself then retries
ENOTEMPTY/EBUSY/EPERM for up to ~0.5 s before giving up. 2243 call sites in 1292
files under tests/, the shared tests/_setup/isolateDataDir.ts exit hook included.
Only the option object changes: no call site, assertion or import is touched.

Validation: prettier and ESLint (with the frozen suppressions) clean on all 1292
files; a random 20-file sample runs green (quota-redis-store hangs identically on
the untouched tree — it needs a Redis on localhost, an environment matter). The
four unit shards on this PR are the full run.
This commit is contained in:
diegosouzapw
2026-08-28 23:56:58 -03:00
parent d7cdfcad43
commit 37ecab3659
1293 changed files with 6367 additions and 5212 deletions

View File

@@ -72,7 +72,7 @@ test.afterEach(() => {
test.after(() => {
globalThis.fetch = originalFetch;
core.resetDbInstance();
fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true });
fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
});
test("Command Code provider catalog has pinned models and alias lookup", () => {
@@ -232,7 +232,9 @@ test("Command Code executor passes the upstream OpenAI SSE stream through untouc
});
};
const { response } = await (await getExecutor("command-code")).execute({
const { response } = await (
await getExecutor("command-code")
).execute({
model: "gpt-5.4",
stream: true,
credentials: { apiKey: "cc_test_key" },
@@ -268,7 +270,9 @@ test("Command Code executor passes the upstream OpenAI JSON through untouched (n
});
};
const { response } = await (await getExecutor("command-code")).execute({
const { response } = await (
await getExecutor("command-code")
).execute({
model: "gpt-5.4-mini",
stream: false,
credentials: { apiKey: "cc_test_key" },
@@ -280,8 +284,11 @@ test("Command Code executor passes the upstream OpenAI JSON through untouched (n
});
test("Command Code executor surfaces upstream errors", async () => {
globalThis.fetch = async () => new Response("bad key", { status: 401, statusText: "Unauthorized" });
const upstreamFailure = await (await getExecutor("command-code")).execute({
globalThis.fetch = async () =>
new Response("bad key", { status: 401, statusText: "Unauthorized" });
const upstreamFailure = await (
await getExecutor("command-code")
).execute({
model: "gpt-5.4-mini",
stream: false,
credentials: { apiKey: "cc_test_key" },
@@ -352,7 +359,9 @@ test("Command Code stream preserves the upstream OpenAI usage chunk (passthrough
globalThis.fetch = async () =>
new Response(sse, { status: 200, headers: { "Content-Type": "text/event-stream" } });
const { response } = await (await getExecutor("command-code")).execute({
const { response } = await (
await getExecutor("command-code")
).execute({
model: "gpt-5.4-mini",
stream: true,
credentials: { apiKey: "cc_test_key" },
@@ -409,7 +418,9 @@ test("Command Code executor falls back to /alpha/generate on 403 (e.g. Go plan w
return new Response("Not found", { status: 404 });
};
const { response, url, headers } = await (await getExecutor("command-code")).execute({
const { response, url, headers } = await (
await getExecutor("command-code")
).execute({
model: "deepseek/deepseek-v4-flash",
stream: true,
credentials: { apiKey: "cc_go_plan_key" },
@@ -456,7 +467,9 @@ test("Command Code executor falls back to /alpha/generate on 403 (Go plan) for n
return new Response("Not found", { status: 404 });
};
const { response } = await (await getExecutor("command-code")).execute({
const { response } = await (
await getExecutor("command-code")
).execute({
model: "gpt-5.4",
stream: false,
credentials: { apiKey: "cc_go_plan_key" },
@@ -484,7 +497,9 @@ test("Command Code executor surfaces fallback error when both /provider/v1 and /
return new Response("error", { status: 500 });
};
const result = await (await getExecutor("command-code")).execute({
const result = await (
await getExecutor("command-code")
).execute({
model: "gpt-5.4",
stream: false,
credentials: { apiKey: "cc_key" },