test: tighten more async polling (#108385)

This commit is contained in:
Peter Steinberger
2026-07-15 10:49:43 -07:00
committed by GitHub
parent 163a9ab5bf
commit 506bb14d22
12 changed files with 16 additions and 16 deletions
+1 -1
View File
@@ -58,7 +58,7 @@ async function waitForChatFinal(
return payload;
}
}
await new Promise((resolve) => setTimeout(resolve, 50));
await new Promise((resolve) => setTimeout(resolve, 10));
}
throw new Error(
`timed out waiting for chat final runId=${runId}; events=${JSON.stringify(
@@ -50,7 +50,7 @@ async function waitForFile(filePath: string, timeoutMs: number): Promise<void> {
if (existsSync(filePath)) {
return;
}
await sleep(25);
await sleep(5);
}
throw new Error(`timeout waiting for ${filePath}`);
}
@@ -61,7 +61,7 @@ async function waitForDead(pid: number, timeoutMs: number): Promise<void> {
if (!isProcessAlive(pid)) {
return;
}
await sleep(25);
await sleep(5);
}
throw new Error(`process still alive: ${pid}`);
}
@@ -69,7 +69,7 @@ async function waitForFile(filePath: string, timeoutMs: number): Promise<void> {
if (fs.existsSync(filePath)) {
return;
}
await sleep(25);
await sleep(5);
}
throw new Error(`timeout waiting for ${filePath}`);
}
@@ -80,7 +80,7 @@ async function waitForDead(pid: number, timeoutMs: number): Promise<void> {
if (!isProcessAlive(pid)) {
return;
}
await sleep(25);
await sleep(5);
}
throw new Error(`process still alive: ${pid}`);
}
+2 -2
View File
@@ -510,9 +510,9 @@ describe("run-oxlint", () => {
" try { process.kill(pid, 0); return true; } catch { return false; }",
"};",
"const waitFor = async (predicate) => {",
" for (let attempt = 0; attempt < 100; attempt += 1) {",
" for (let attempt = 0; attempt < 500; attempt += 1) {",
" if (predicate()) return true;",
" await sleep(25);",
" await sleep(5);",
" }",
" return false;",
"};",
@@ -75,7 +75,7 @@ async function waitFor(predicate: () => boolean, timeoutMs = 5_000): Promise<voi
if (predicate()) {
return;
}
await delay(25);
await delay(5);
}
throw new Error("condition was not met before timeout");
}
+2 -2
View File
@@ -66,7 +66,7 @@ async function waitForFile(filePath: string, timeoutMs: number): Promise<void> {
if (fs.existsSync(filePath)) {
return;
}
await sleep(25);
await sleep(5);
}
throw new Error(`timed out waiting for ${filePath}`);
}
@@ -77,7 +77,7 @@ async function waitForDead(pid: number, timeoutMs: number): Promise<void> {
if (!isProcessAlive(pid)) {
return;
}
await sleep(25);
await sleep(5);
}
throw new Error(`timed out waiting for pid ${pid} to exit`);
}
+1 -1
View File
@@ -47,7 +47,7 @@ async function waitForRequests(
return requests;
}
await new Promise((resolve) => {
setTimeout(resolve, 50);
setTimeout(resolve, 10);
});
}
throw new Error(`Timed out waiting for ${count} ${method} requests`);
+1 -1
View File
@@ -69,7 +69,7 @@ async function waitForCronListRequest(
return match;
}
await new Promise((resolve) => {
setTimeout(resolve, 50);
setTimeout(resolve, 10);
});
}
throw new Error(`No matching cron.list request found: ${JSON.stringify(requests)}`);
+1 -1
View File
@@ -108,7 +108,7 @@ async function waitForPatch(
return match;
}
await new Promise((resolve) => {
setTimeout(resolve, 50);
setTimeout(resolve, 10);
});
}
throw new Error(`No matching sessions.patch request found: ${JSON.stringify(requests)}`);
+1 -1
View File
@@ -206,7 +206,7 @@ async function waitForNextRequest(
}
}
await new Promise<void>((resolve) => {
setTimeout(resolve, 50);
setTimeout(resolve, 10);
});
}
throw new Error(`Timed out waiting for the next ${method} request`);
@@ -197,7 +197,7 @@ async function waitForRequestCount(
stableSince = null;
}
await new Promise((resolve) => {
setTimeout(resolve, 50);
setTimeout(resolve, 10);
});
}
throw new Error(
+1 -1
View File
@@ -117,7 +117,7 @@ async function waitForRequests(
return requests;
}
await new Promise((resolve) => {
setTimeout(resolve, 50);
setTimeout(resolve, 10);
});
}
throw new Error(`Timed out waiting for ${count} ${method} requests`);