Skip to content

fix(resume): preload pdfjs worker so Vercel bundles it and parsing wo…#95

Closed
RikepilB wants to merge 1 commit into
masterfrom
fix/prod-pdfjs-worker-bundling
Closed

fix(resume): preload pdfjs worker so Vercel bundles it and parsing wo…#95
RikepilB wants to merge 1 commit into
masterfrom
fix/prod-pdfjs-worker-bundling

Conversation

@RikepilB

@RikepilB RikepilB commented Jun 11, 2026

Copy link
Copy Markdown
Owner

…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.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added PDF text extraction functionality to the application.
  • Improvements

    • Enhanced PDF processing reliability with improved error handling and fallback support.

…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.
@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 Building Building Preview, Comment Jun 11, 2026 9:25pm

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d4a6d007-dcc4-4292-92be-85dd6764782a

📥 Commits

Reviewing files that changed from the base of the PR and between 21ba1ad and a59cecd.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • .gitignore
  • package.json
  • src/lib/resume/extractText.ts
  • src/types/globals.d.ts

📝 Walkthrough

Walkthrough

This PR introduces PDF.js support for resume text extraction with worker preload and Node.js canvas polyfilling, while also expanding the project's .gitignore to exclude Playwright test artifacts. The changes address Vercel/Node runtime incompatibilities with missing DOM globals and worker bundles.

Changes

PDF.js Integration for Text Extraction

Layer / File(s) Summary
Dependency and Type Declarations
package.json, src/types/globals.d.ts
Adds pdfjs-dist v5.4.296 to dependencies and declares a TypeScript ambient module for the PDF.js worker .mjs build, documenting that it is imported for its side effect of setting globalThis.pdfjsWorker.
Worker Preload and Canvas Polyfill
src/lib/resume/extractText.ts
Updates ensurePdfDomGlobals() to preload the PDF.js worker module and conditionally polyfill missing DOMMatrix, ImageData, and Path2D globals from @napi-rs/canvas when running on Node.js, with polyfill and worker preload errors logged as warnings rather than thrown.

Test Artifact Ignore Patterns

Layer / File(s) Summary
Playwright Artifacts Ignore
.gitignore
Adds ignore patterns for playwright-report/ and playwright-mcp/ directories to prevent Playwright test artifacts from being tracked.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A worker arrives, canvas polyfills dance,
PDFs now parse in the serverless expanse,
Playwright reports hide away with care,
Sweet extraction blooms in the Node.js air! ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/prod-pdfjs-worker-bundling

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


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

@RikepilB RikepilB closed this Jun 11, 2026
@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