Repository navigation
Conversation
🦋 Changeset detectedLatest commit: 5bc7f7e The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
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 |
|
@ntltd is attempting to deploy a commit to the diegomura Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
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.
Refs #3225
What
In the browser, every image logs
Buffer is not definedwhile the document renders.fetchImage(@react-pdf/layout) callsBuffer.isBuffer(source)right after the image is resolved; browsers have noBufferglobal, so it throws, thecatchlogs the message, andnode.image.keyis never set for url or data-URI sources.The image itself is already loaded at that point, so documents render fine: the visible effects are one warning per image and the missing cache key.
Change
fetchImagecheckssource instanceof Uint8Arrayinstead ofBuffer.isBuffer(source). A NodeBufferis aUint8Array, so the behaviour on Node is unchanged; in line with refactor(pdfkit): replace Buffer usage with Uint8Array #3487, which removedBufferfrom pdfkit.fetchImage: url source keyed, url source keyed withBufferstubbed out (as in browsers), buffer and blob sources not keyed, and no warning in any case.@react-pdf/layoutpatch.How to check
yarn vitest run packages/layout/tests/image/fetchImage.test.ts. The "Buffer is not defined" case fails without the change.Seen with
@react-pdf/renderer4.9.0 /@react-pdf/layout5.2.0 in a Vite app (Chrome), 8 to 26 warnings per generated document.