Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions apps/server/src/files/pdf-text.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<number> {
let closed = () => {};
const disconnected = new Promise<void>((resolve) => {
Expand All @@ -59,7 +62,7 @@ async function workerErrorExit(bytes: Uint8Array): Promise<number> {
const timer = setTimeout(() => {
timedOut = true;
worker.kill();
}, 5000);
}, SLOW_WORKER_MS);
try {
await worker.stdin.write(bytes);
await worker.stdin.end();
Expand Down Expand Up @@ -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,
Expand All @@ -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 = () => {};
Expand Down
Loading