-
-
Notifications
You must be signed in to change notification settings - Fork 760
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
Encoder for GIF provides a Promise to getBuffer when a string, Buffer, or Uint8Array is expected #1239
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
…nstance of Buffer or Uint8Array. Received an instance of Promise.
stevezac-osu
changed the title
Resolving Issue 980
Encoder for GIF provides a Promise to getBuffer when a string, Buffer, or Uint8Array is expected
May 31, 2023
please merge this pr. |
@stevezac-osu thank you for finding (and fixing!) the issue many of us are experiencing. I implemented your change locally, and it worked great! 👍🎉 |
🚀 PR was released in |
This was referenced May 24, 2024
This was referenced May 25, 2024
This was referenced May 29, 2024
This was referenced Aug 10, 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.
Fixing Issue 980: The 'chunk' argument must be of type string or an Instance of Buffer or Uint8Array. Received an instance of Promise.
What's Changing and Why
On jimp/packages/core/src/utils/image-bitmap.js getBuffer(mime, cb) function, the method is intended to provide a string or a buffer to a callback function so that the callback can consume such buffer (typically with the Write function).
However, occasionally the following error will occur ( see also #980 ):
I traced the issue back to the fact that one of the encoders, the GIF encoder, consistently returns a promise rather than a string or a buffer response. See jimp/packages/type-gif/src/index.js line 34.
Rather than solve this issue at the GIF encoder (if that could be solved at all), it seemed like a better idea to make the get buffer function more robust by permitting encoders to return a promise as a valid data type and handle such a response gracefully.
Accordingly, on jimp/packages/core/src/utils/image-bitmap.js getBuffer(mime, cb), I have added
What else might be affected
n/a