Skip to content

Commit

Permalink
Encoder for GIF provides a Promise to getBuffer when a string, Buffer…
Browse files Browse the repository at this point in the history
…, or Uint8Array is expected (#1239)

* Fixing Issue 980: The 'chunk' argument must be of type string or an instance of Buffer or Uint8Array. Received an instance of Promise.

* fix lint

---------

Co-authored-by: Andrew Lisowski <lisowski54@gmail.com>
  • Loading branch information
stevezac-osu and hipstersmoothie committed Jul 26, 2023
1 parent 244e366 commit 0a404ca
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/core/src/utils/image-bitmap.js
Expand Up @@ -225,7 +225,15 @@ export function getBuffer(mime, cb) {

if (this.constructor.encoders[mime]) {
const buffer = this.constructor.encoders[mime](this);
cb.call(this, null, buffer);
// Typically, buffers return a string or map. However, the gif library "gifwrap" seemingly returns promises.
if (buffer instanceof Promise) {
// trigger the callback when the promise has been resolved
buffer.then((buff) => {
cb.call(this, null, buff);
});
} else {
cb.call(this, null, buffer);
}
} else {
return throwError.call(this, "Unsupported MIME type: " + mime, cb);
}
Expand Down

0 comments on commit 0a404ca

Please sign in to comment.