From a645d1868f35dc6171c0b4985262cb183eba09dd Mon Sep 17 00:00:00 2001 From: Laura Thiel Date: Tue, 17 Nov 2026 15:04:10 +0100 Subject: [PATCH] test(files): give oversized PDF extraction time under load The text-limit test and workerErrorExit allowed 5 s. Under a loaded parallel suite the 180-page extraction ran past that and returned "PDF extraction timed out", or tripped the helper's own timer, so the test failed although the text limit worked. Both now allow 30 s, and the test 60 s. --- apps/server/src/files/pdf-text.test.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/server/src/files/pdf-text.test.ts b/apps/server/src/files/pdf-text.test.ts index 17588e5e..cdc67526 100644 --- a/apps/server/src/files/pdf-text.test.ts +++ b/apps/server/src/files/pdf-text.test.ts @@ -37,6 +37,9 @@ function oversizedTextPdf(pages: number): Uint8Array { return new TextEncoder().encode(pdf); } +/** Far above an oversized PDF's extraction time, so a loaded machine still reaches the worker's own limits before a timer. */ +const SLOW_WORKER_MS = 30_000; + async function workerErrorExit(bytes: Uint8Array): Promise { let closed = () => {}; const disconnected = new Promise((resolve) => { @@ -59,7 +62,7 @@ async function workerErrorExit(bytes: Uint8Array): Promise { const timer = setTimeout(() => { timedOut = true; worker.kill(); - }, 5000); + }, SLOW_WORKER_MS); try { await worker.stdin.write(bytes); await worker.stdin.end(); @@ -122,7 +125,7 @@ describe("extractPdfText", () => { ], sampleRss: async () => 1024 * 1024, }; - const limits = { ms: 5000, memoryMib: 512 }; + const limits = { ms: SLOW_WORKER_MS, memoryMib: 512 }; const onePage = await runPdfExtraction( oversizedTextPdf(1), limits, @@ -142,7 +145,7 @@ describe("extractPdfText", () => { "PDF extraction failed", "PDF memory measurement unavailable", ]).toContain(real.reason); - }, 15000); + }, 60_000); test("completion waits for an in-flight RSS sample", async () => { let release = () => {}; let started = () => {};