From 7852aacd113c2bd72ff248ca7abbcdea955cfedd Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Wed, 30 Oct 2024 07:05:44 +1000 Subject: [PATCH] fix(uI): track whether graph succeeded in runGraphAndReturnImageOutput This prevents extraneous graph cancel requests when cleaning up the abort signal after a successful run of a graph. --- .../controlLayers/konva/CanvasStateApiModule.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/invokeai/frontend/web/src/features/controlLayers/konva/CanvasStateApiModule.ts b/invokeai/frontend/web/src/features/controlLayers/konva/CanvasStateApiModule.ts index e1b6b6dc1a..929e13be7c 100644 --- a/invokeai/frontend/web/src/features/controlLayers/konva/CanvasStateApiModule.ts +++ b/invokeai/frontend/web/src/features/controlLayers/konva/CanvasStateApiModule.ts @@ -293,6 +293,8 @@ export class CanvasStateApiModule extends CanvasModuleBase { }, }; + let didSuceed = false; + /** * If a timeout is provided, we will cancel the graph if it takes too long - but we need a way to clear the timeout * if the graph completes or errors before the timeout. @@ -344,6 +346,8 @@ export class CanvasStateApiModule extends CanvasModuleBase { return; } + didSuceed = true; + // Ok! resolve(getImageDTOResult.value); }; @@ -434,6 +438,10 @@ export class CanvasStateApiModule extends CanvasModuleBase { if (timeout) { timeoutId = window.setTimeout(() => { + if (didSuceed) { + // If we already succeeded, we don't need to do anything + return; + } this.log.trace('Graph canceled by timeout'); clearListeners(); cancelGraph(); @@ -443,6 +451,10 @@ export class CanvasStateApiModule extends CanvasModuleBase { if (signal) { signal.addEventListener('abort', () => { + if (didSuceed) { + // If we already succeeded, we don't need to do anything + return; + } this.log.trace('Graph canceled by signal'); _clearTimeout(); clearListeners();