Skip to content

fix: bump pdfkit to 0.20.2 for tracer-safe standard fonts - #3550

Closed
mrowe wants to merge 1 commit into
diegomura:masterfrom
mrowe:bump-pdfkit-0.20.2
Closed

fix: bump pdfkit to 0.20.2 for tracer-safe standard fonts#3550
mrowe wants to merge 1 commit into
diegomura:masterfrom
mrowe:bump-pdfkit-0.20.2

Conversation

@mrowe

@mrowe mrowe commented Sep 1, 2026

Copy link
Copy Markdown

What

Bumps the exact pdfkit pin in @react-pdf/font and @react-pdf/renderer from 0.20.1 to 0.20.2, with a patch changeset for both packages. The lockfile regeneration also let yarn re-normalize one previously merged babel entry.

Why

pdfkit 0.20.0/0.20.1 map #standard-fonts/* to .cjs under the require condition but .mjs under default. Node resolves the .cjs files at runtime, while file tracers and bundlers — e.g. @vercel/nft, which builds Next.js output: 'standalone' deployments — resolve the .mjs twins. The traced output therefore omits the modules the Node build actually lazy-loads, the build succeeds, and the first server-side render throws:

Error: Cannot find module '/app/node_modules/pdfkit/js/standard-fonts/Helvetica.cjs'

Helvetica is the default font, so any document without registered fonts hits this immediately. We hit this in production after upgrading @react-pdf/renderer 4.5.1 → 4.9.0 (the 4.8.0 fork→upstream pdfkit swap): guest receipt PDFs 500'd in the deployed container while local dev and the build itself were green.

pdfkit 0.20.2 fixes this upstream (foliojs/pdfkit#1782) by resolving the subpath to one file under every condition, so tracers pack what runtime loads. 0.20.1 → 0.20.2 is patch-only with no API change.

Verified in our Next.js standalone deployment: with 0.20.2 (via npm overrides) the traced output contains all 14 standard-fonts/*.cjs files and server-side rendering works; with 0.20.1 it contains none of them.

Note this is unrelated to #3532 (TypeError: Invalid URL from import.meta.url under ESBuild-to-CJS transpilation) — different mechanism, not fixed by this bump.

🤖 Generated with Claude Code

https://claude.ai/code/session_013Z4s94hfd1MWA6TnLmRXEb

pdfkit 0.20.0/0.20.1 mapped '#standard-fonts/*' to .cjs under the
'require' condition but .mjs under 'default'. Node resolves the .cjs
files at runtime, while file tracers and bundlers (e.g. @vercel/nft
behind Next.js standalone output) resolve the .mjs twins - so traced
deployments omit the modules the Node build actually loads and the
first render throws:

  Cannot find module '.../pdfkit/js/standard-fonts/Helvetica.cjs'

pdfkit 0.20.2 (foliojs/pdfkit#1782) resolves the subpath to one file
under every condition, so traced output matches runtime. Patch-only
upgrade, no API change.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Z4s94hfd1MWA6TnLmRXEb
@vercel

vercel Bot commented Sep 1, 2026

Copy link
Copy Markdown

@mrowe is attempting to deploy a commit to the diegomura Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8be3fe3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@react-pdf/font Patch
@react-pdf/renderer Patch
@react-pdf/types Patch
@react-pdf/math Patch
@react-pdf/mermaid Patch
@react-pdf/ui Patch
@react-pdf/examples Patch
@react-pdf/layout Patch
@react-pdf/render Patch
@react-pdf/stylesheet Patch
@react-pdf/tailwind Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@mrowe
mrowe marked this pull request as ready for review September 1, 2026 01:41
@mrowe mrowe closed this Sep 1, 2026
@mrowe
mrowe deleted the bump-pdfkit-0.20.2 branch September 1, 2026 06:13
@VladSez

VladSez commented Sep 2, 2026

Copy link
Copy Markdown

@mrowe why this was closed?

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