fix(resume): preload pdfjs worker so Vercel bundles it and prod PDF parsing works#96
Merged
Merged
Conversation
…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.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Prod PDF parsing still failed after the DOMMatrix polyfill (PR #93). Vercel runtime logs:
pdfjs resolves its worker via a runtime-computed
import(workerSrc)that Vercel's file tracer cannot follow, sopdf.worker.mjsnever made it into the deployed function bundle.Fix
import("pdfjs-dist/legacy/build/pdf.worker.mjs")inextractText.tsbefore pdf-parse loads:globalThis.pdfjsWorker, which pdfjs prefers over dynamically importingworkerSrc(verified in pdf.mjs_setupFakeWorkerGlobal)pdfjs-dist@5.4.296exact as a direct dep, matching pdf-parse's transitive version, so the preloaded worker and parser are the same buildplaywright-report/and.playwright-mcp/artifactsTest plan
pnpm lint(1 pre-existing font warning only)pnpm typecheckpnpm vitest run— 196 passedVerified this deploy round (prod)
🤖 Generated with Claude Code