Skip to content

test(files): give oversized PDF extraction time under load - #147

Merged
cheetahbyte merged 2 commits into
mainfrom
test/pdf-text-limit-timeout
Nov 20, 2026
Merged

cheetahbyte merged 2 commits into
mainfrom
test/pdf-text-limit-timeout

Conversation

@lauragarden

Copy link
Copy Markdown
Contributor

Summary

extractPdfText > worker text limit fails without a timeout now allows 30 s for each oversized PDF extraction instead of 5 s, and 60 s for the whole test instead of 15 s. workerErrorExit, which has its own guard timer, uses the same SLOW_WORKER_MS constant. The other tests' 5 s limits are unchanged; they extract small fixtures.

Why

The test checks that the text limit stops a 180-page PDF before any timeout. Under a loaded parallel suite, the extraction itself took longer than 5 s, so the test failed although the text limit worked:

  • runPdfExtraction returned "PDF extraction timed out" instead of "PDF extraction failed" (line 136).
  • With only that limit raised, workerErrorExit's 5 s guard fired instead (expect(timedOut).toBe(false), line 67).

It failed in 2 of 3 local pre-push runs and blocked a push of #146. CI on main passed.

Evidence

Load reproduction: 16 copies of the test running at once (bun test apps/server/src/files/pdf-text.test.ts -t "worker text limit fails without a timeout"), on the same machine:

Limits Result
main (5 s / 5 s) 10 of 16 failed, all with "PDF extraction timed out"
Extraction limit 30 s, workerErrorExit 5 s 14 of 16 failed in workerErrorExit
This PR (30 s / 30 s, test 60 s) 32 of 32 passed over two rounds; slowest test took 22.5 s

Alone, the test still takes about 3.5 s. bun run check passes: 1316 tests, 0 failing.

Risk and rollback

Reversibility: Reversible.

Blast radius: One test file; no production code changes.

If extraction ever really hangs, the test now takes up to 60 s to fail instead of 15 s.

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.
@cheetahbyte
cheetahbyte merged commit e4e6e08 into main Nov 20, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants