From e91c99d96bc2e56243ffba1047c824d11db9e53b Mon Sep 17 00:00:00 2001 From: Zach Stevenson Date: Mon, 29 May 2023 02:46:45 -0400 Subject: [PATCH 1/2] Fixing Issue 980: The 'chunk' argument must be of type string or an instance of Buffer or Uint8Array. Received an instance of Promise. --- packages/core/src/utils/image-bitmap.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/core/src/utils/image-bitmap.js b/packages/core/src/utils/image-bitmap.js index 6b2717d11..557805d71 100644 --- a/packages/core/src/utils/image-bitmap.js +++ b/packages/core/src/utils/image-bitmap.js @@ -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); } From 0aa29d274cdfffcba4d41bca8f3f50319c0fd08f Mon Sep 17 00:00:00 2001 From: Andrew Lisowski Date: Wed, 26 Jul 2023 11:51:18 -0700 Subject: [PATCH 2/2] fix lint --- packages/core/src/utils/image-bitmap.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core/src/utils/image-bitmap.js b/packages/core/src/utils/image-bitmap.js index 557805d71..fe377cbd9 100644 --- a/packages/core/src/utils/image-bitmap.js +++ b/packages/core/src/utils/image-bitmap.js @@ -225,12 +225,12 @@ export function getBuffer(mime, cb) { if (this.constructor.encoders[mime]) { const buffer = this.constructor.encoders[mime](this); - //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 + // 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); }