mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-21 02:06:43 +00:00
test: tighten more async polling (#108385)
This commit is contained in:
@@ -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}`);
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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`);
|
||||
}
|
||||
|
||||
@@ -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`);
|
||||
|
||||
@@ -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)}`);
|
||||
|
||||
@@ -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)}`);
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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`);
|
||||
|
||||
Reference in New Issue
Block a user