Skip to content

fix(image,react-pdf): resolve Buffer/stream type errors breaking build - #304

Open
ctate wants to merge 1 commit into
mainfrom
fix/node-buffer-types
Open

fix(image,react-pdf): resolve Buffer/stream type errors breaking build#304
ctate wants to merge 1 commit into
mainfrom
fix/node-buffer-types

Conversation

@ctate

@ctate ctate commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

@json-render/image and @json-render/react-pdf currently fail build (dts) and check-types on main:

image/src/render.tsx(209,3): error TS2322: Type 'Buffer' is not assignable to type 'Uint8Array<ArrayBufferLike>'.
react-pdf/src/render.tsx(156,3): error TS2322: Type 'Buffer' is not assignable to type 'Uint8Array<ArrayBufferLike>'.
react-pdf/src/render.tsx(167,3): error TS2740: Type 'ReadableStream' is missing the following properties from type 'ReadableStream<any>': locked, cancel, getReader, ...

Since the release workflow's publish job runs pnpm run build, this blocks the next release.

Fix

  • renderToPng / renderToBuffer: @resvg/resvg-js's asPng() and @react-pdf/renderer's renderToBuffer() return Node Buffer; wrap in zero-copy Uint8Array views to satisfy the declared platform-neutral return types.
  • renderToStream: was declared Promise<ReadableStream> (web), but @react-pdf/renderer's renderToStream() actually resolves to a NodeJS.ReadableStream. Declare what it really returns — treating the old type as a web stream would fail at runtime.

Verification

All 24 package builds pass and 1021/1021 unit tests pass on this branch; both failures reproduce on unmodified main.

@resvg/resvg-js's asPng() and @react-pdf/renderer's renderToBuffer()
return Node Buffer, which no longer satisfies the declared Uint8Array
return types under the current @types/node/TypeScript resolution,
failing dts builds (and therefore the release workflow's build step).
Wrap the Buffers in zero-copy Uint8Array views.

renderToStream() was declared as returning a web ReadableStream, but
@react-pdf/renderer's renderToStream() actually resolves to a
NodeJS.ReadableStream; declare what it really returns.
@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
json-render Ready Ready Preview, Comment Jul 1, 2026 11:56pm
json-render-chat-demo Ready Ready Preview, Comment Jul 1, 2026 11:56pm
json-render-dashboard-demo Ready Ready Preview, Comment Jul 1, 2026 11:56pm
json-render-game-engine-demo Ready Ready Preview, Comment Jul 1, 2026 11:56pm
json-render-image-demo Ready Ready Preview, Comment Jul 1, 2026 11:56pm
json-render-no-ai Ready Ready Preview, Comment Jul 1, 2026 11:56pm
json-render-react-email-demo Ready Ready Preview, Comment Jul 1, 2026 11:56pm
json-render-react-pdf-demo Error Error Jul 1, 2026 11:56pm
json-render-react-three-fiber-demo Ready Ready Preview, Comment Jul 1, 2026 11:56pm
json-render-remotion-demo Ready Ready Preview, Comment Jul 1, 2026 11:56pm
json-render-solid-demo Ready Ready Preview, Comment Jul 1, 2026 11:56pm
json-render-svelte-chat-demo Ready Ready Preview, Comment Jul 1, 2026 11:56pm
json-render-svelte-demo Ready Ready Preview, Comment Jul 1, 2026 11:56pm
json-render-vue Ready Ready Preview, Comment Jul 1, 2026 11:56pm

spec: Spec,
options?: RenderOptions,
): Promise<ReadableStream> {
): Promise<NodeJS.ReadableStream> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use of NodeJS.ReadableStream in renderToStream's return type breaks the DTS build because @types/node is not a dependency of @json-render/react-pdf, so the NodeJS global namespace is unresolvable (TS2503).

Fix on Vercel

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