-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(gatsby-plugin-sharp): pass input buffer instead of readStream when processing image jobs #33685
Merged
Conversation
This file contains 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
…n processing image jobs
gatsbot
bot
added
the
status: triage needed
Issue or pull request that need to be triaged and assigned to a reviewer
label
Oct 26, 2021
pieh
added
topic: media
Related to gatsby-plugin-image, or general image/media processing topics
and removed
status: triage needed
Issue or pull request that need to be triaged and assigned to a reviewer
labels
Oct 26, 2021
wardpeet
approved these changes
Oct 27, 2021
wardpeet
pushed a commit
that referenced
this pull request
Oct 27, 2021
…n processing image jobs (#33685) (#33694) Co-authored-by: Michal Piechowiak <[email protected]>
vladar
pushed a commit
that referenced
this pull request
Oct 28, 2021
…n processing image jobs (#33685) (#33703) (cherry picked from commit b800559) Co-authored-by: Michal Piechowiak <[email protected]>
wardpeet
pushed a commit
to herecydev/gatsby
that referenced
this pull request
Oct 29, 2021
…n processing image jobs (gatsbyjs#33685)
axe312ger
pushed a commit
that referenced
this pull request
Nov 9, 2021
…n processing image jobs (#33685)
This was referenced Jun 6, 2022
This was referenced Apr 15, 2024
This was referenced Apr 15, 2024
This was referenced Apr 15, 2024
This was referenced Apr 15, 2024
This was referenced Apr 15, 2024
This was referenced Apr 15, 2024
This was referenced Apr 15, 2024
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.
Description
With single readStream and multiple sharp pipelines there is opportunity for mishandling / not syncing things properly. In particular our setup was piping readStream too early (it should pipe it after all pipelines were created, but this ended up not being easy task due to way
duotone
option is handled, which essentially "consumes" pipeline build so far and building another pipeline on top of that).I did check
sharp
internals, and it seems like there is no actual benefit of using streams over buffers, because sharp internally will "convert" stream to buffer anyway, before passing it to native land:https://github.com/lovell/sharp/blob/319db21f29a3c838fe52aa0713a10837581e831c/lib/output.js#L1099-L1116
This is where JS pass things to C++ land, notice how it's not streaming, it just wait for
readStream
to finish and reader of data to push everything to buffer. Similarly C++ side of it only handle 2 cases - buffer or filepath (no mention of streams) - https://github.com/lovell/sharp/blob/319db21f29a3c838fe52aa0713a10837581e831c/src/common.cc#L77-L87We do have still other cases of using read streams as input in plugin, but those are not problematic so far and they use single stream + single output model, so not converting them to buffers to focus on place with actual problem
Related Issues
Fixes #33557
[ch40306]