mirror of
https://github.com/murashit/codex-panel.git
synced 2026-07-22 17:30:31 +00:00
15 lines
419 B
TypeScript
15 lines
419 B
TypeScript
export async function waitForAsyncWork(assertion: () => void): Promise<void> {
|
|
let lastError: unknown;
|
|
for (let attempt = 0; attempt < 20; attempt += 1) {
|
|
try {
|
|
assertion();
|
|
return;
|
|
} catch (error) {
|
|
lastError = error;
|
|
await Promise.resolve();
|
|
}
|
|
}
|
|
assertion();
|
|
if (lastError instanceof Error) throw lastError;
|
|
throw new Error("Timed out waiting for async test work.");
|
|
}
|