mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-02-02 22:35:15 -05:00
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.
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user