From 4e74006c5fff3e4006669fc0c74fa484a1f7856a Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Fri, 30 Aug 2024 22:02:14 +1000 Subject: [PATCH] fix(ui): canvasToBlob not raising error correctly --- .../web/src/features/controlLayers/konva/util.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/invokeai/frontend/web/src/features/controlLayers/konva/util.ts b/invokeai/frontend/web/src/features/controlLayers/konva/util.ts index c6e42aca27..b434b90646 100644 --- a/invokeai/frontend/web/src/features/controlLayers/konva/util.ts +++ b/invokeai/frontend/web/src/features/controlLayers/konva/util.ts @@ -302,10 +302,13 @@ export const konvaNodeToCanvas = (node: Konva.Node, bbox?: Rect): HTMLCanvasElem * @returns A Promise that resolves with Blob of the node cropped to the bounding box */ export const canvasToBlob = (canvas: HTMLCanvasElement): Promise => { - return new Promise((resolve) => { + return new Promise((resolve, reject) => { canvas.toBlob((blob) => { - assert(blob, 'blob is null'); - resolve(blob); + if (!blob) { + reject('Failed to convert canvas to blob'); + } else { + resolve(blob); + } }); }); };