From e8352c8d2122e55b572e02de73e9941ae2025855 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 23 Jan 2026 07:10:59 +0000 Subject: [PATCH] fix: stabilize cron log wait --- src/gateway/server.cron.test.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gateway/server.cron.test.ts b/src/gateway/server.cron.test.ts index 23413bae6..2993dccb6 100644 --- a/src/gateway/server.cron.test.ts +++ b/src/gateway/server.cron.test.ts @@ -53,14 +53,15 @@ async function waitForCronFinished( } async function waitForNonEmptyFile(pathname: string, timeoutMs = 2000) { - const deadline = Date.now() + timeoutMs; + const startedAt = process.hrtime.bigint(); for (;;) { const raw = await fs.readFile(pathname, "utf-8").catch(() => ""); if (raw.trim().length > 0) return raw; - if (Date.now() >= deadline) { + const elapsedMs = Number(process.hrtime.bigint() - startedAt) / 1e6; + if (elapsedMs >= timeoutMs) { throw new Error(`timeout waiting for file ${pathname}`); } - await new Promise((resolve) => setTimeout(resolve, 10)); + await yieldToEventLoop(); } }