Skip to content

fix(resume): preload pdfjs worker so Vercel bundles it and prod PDF parsing works#96

Merged
RikepilB merged 1 commit into
mainfrom
fix/prod-pdfjs-worker-bundling
Jun 11, 2026
Merged

fix(resume): preload pdfjs worker so Vercel bundles it and prod PDF parsing works#96
RikepilB merged 1 commit into
mainfrom
fix/prod-pdfjs-worker-bundling

Conversation

@RikepilB

Copy link
Copy Markdown
Owner

Problem

Prod PDF parsing still failed after the DOMMatrix polyfill (PR #93). Vercel runtime logs:

[parse] failed for applicant cmqa01cep000104jx9ofb01fp: Error: Setting up fake worker failed: "Cannot find module '/var/task/node_modules/.pnpm/pdfjs-dist@5.4.296/node_modules/pdfjs-dist/legacy/build/pdf.worker.mjs' ..."

pdfjs resolves its worker via a runtime-computed import(workerSrc) that Vercel's file tracer cannot follow, so pdf.worker.mjs never made it into the deployed function bundle.

Fix

  • Eagerly import("pdfjs-dist/legacy/build/pdf.worker.mjs") in extractText.ts before pdf-parse loads:
    • the literal specifier lets the tracer bundle the worker file
    • the module sets globalThis.pdfjsWorker, which pdfjs prefers over dynamically importing workerSrc (verified in pdf.mjs _setupFakeWorkerGlobal)
  • Pin pdfjs-dist@5.4.296 exact as a direct dep, matching pdf-parse's transitive version, so the preloaded worker and parser are the same build
  • Gitignore playwright-report/ and .playwright-mcp/ artifacts

Test plan

  • pnpm lint (1 pre-existing font warning only)
  • pnpm typecheck
  • pnpm vitest run — 196 passed
  • Post-deploy: submit PDF application on prod → parsingStatus COMPLETED

Verified this deploy round (prod)

  • Email pacing works: 5-recipient fan-out spaced ~400ms, zero 429s (only expected Resend testing-mode rejections)
  • DOMMatrix error gone (replaced by this worker-bundling error, now fixed)

🤖 Generated with Claude Code

…rks in prod

Production PDF parsing failed with:
  Setting up fake worker failed: "Cannot find module '.../pdfjs-dist/legacy/build/pdf.worker.mjs'"

pdfjs resolves its worker via a runtime-computed import that Vercel's file
tracer cannot follow, so pdf.worker.mjs never made it into the deployed
bundle. Importing the worker module eagerly (before pdf-parse loads) fixes
both halves: the literal specifier gets the file traced into the bundle,
and the import sets globalThis.pdfjsWorker, which pdfjs prefers over
dynamically importing workerSrc.

pdfjs-dist is pinned exact (5.4.296) to match pdf-parse's transitive
dependency so the preloaded worker and the parser are the same build.

Also gitignore playwright-report/ and .playwright-mcp/ artifacts.
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9c77c67f-4a3d-4456-b8b1-0cf9abd120f2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/prod-pdfjs-worker-bundling

Comment @coderabbitai help to get the list of available commands and usage tips.

@vercel

vercel Bot commented Jun 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
scoutlane Ready Ready Preview, Comment Jun 11, 2026 9:27pm

@RikepilB RikepilB merged commit c7d7f9f into main Jun 11, 2026
5 checks passed
@RikepilB RikepilB deleted the fix/prod-pdfjs-worker-bundling branch June 11, 2026 21:28
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.

1 participant