mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-09 22:24:05 -08:00
Revert "getExecution
can now return undefined if there is no active execution for that id"
This reverts commit 047b1d13c0
.
This commit is contained in:
parent
047b1d13c0
commit
f19fcb2c0b
|
@ -127,20 +127,14 @@ export class ActiveExecutions {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
attachWorkflowExecution(executionId: string, workflowExecution: PCancelable<IRun>) {
|
attachWorkflowExecution(executionId: string, workflowExecution: PCancelable<IRun>) {
|
||||||
const execution = this.getExecution(executionId);
|
this.getExecution(executionId).workflowExecution = workflowExecution;
|
||||||
if (execution) {
|
|
||||||
execution.workflowExecution = workflowExecution;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
attachResponsePromise(
|
attachResponsePromise(
|
||||||
executionId: string,
|
executionId: string,
|
||||||
responsePromise: IDeferredPromise<IExecuteResponsePromiseData>,
|
responsePromise: IDeferredPromise<IExecuteResponsePromiseData>,
|
||||||
): void {
|
): void {
|
||||||
const execution = this.getExecution(executionId);
|
this.getExecution(executionId).responsePromise = responsePromise;
|
||||||
if (execution) {
|
|
||||||
execution.responsePromise = responsePromise;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resolveResponsePromise(executionId: string, response: IExecuteResponsePromiseData): void {
|
resolveResponsePromise(executionId: string, response: IExecuteResponsePromiseData): void {
|
||||||
|
@ -151,31 +145,23 @@ export class ActiveExecutions {
|
||||||
/** Cancel the execution promise and reject its post-execution promise. */
|
/** Cancel the execution promise and reject its post-execution promise. */
|
||||||
stopExecution(executionId: string): void {
|
stopExecution(executionId: string): void {
|
||||||
const execution = this.getExecution(executionId);
|
const execution = this.getExecution(executionId);
|
||||||
if (execution) {
|
execution.workflowExecution?.cancel();
|
||||||
execution.workflowExecution?.cancel();
|
execution.postExecutePromise.reject(new ExecutionCancelledError(executionId));
|
||||||
execution.postExecutePromise.reject(new ExecutionCancelledError(executionId));
|
this.logger.debug('Execution cancelled', { executionId });
|
||||||
this.logger.debug('Execution cancelled', { executionId });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Resolve the post-execution promise in an execution. */
|
/** Resolve the post-execution promise in an execution. */
|
||||||
finalizeExecution(executionId: string, fullRunData?: IRun) {
|
finalizeExecution(executionId: string, fullRunData?: IRun) {
|
||||||
const execution = this.getExecution(executionId);
|
const execution = this.getExecution(executionId);
|
||||||
if (execution) {
|
execution.postExecutePromise.resolve(fullRunData);
|
||||||
execution.postExecutePromise.resolve(fullRunData);
|
this.logger.debug('Execution finalized', { executionId });
|
||||||
this.logger.debug('Execution finalized', { executionId });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a promise which will resolve with the data of the execution with the given id
|
* Returns a promise which will resolve with the data of the execution with the given id
|
||||||
*/
|
*/
|
||||||
async getPostExecutePromise(executionId: string): Promise<IRun | undefined> {
|
async getPostExecutePromise(executionId: string): Promise<IRun | undefined> {
|
||||||
const execution = this.getExecution(executionId);
|
return await this.getExecution(executionId).postExecutePromise.promise;
|
||||||
if (execution) {
|
|
||||||
return await execution.postExecutePromise.promise;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -202,14 +188,11 @@ export class ActiveExecutions {
|
||||||
}
|
}
|
||||||
|
|
||||||
setStatus(executionId: string, status: ExecutionStatus) {
|
setStatus(executionId: string, status: ExecutionStatus) {
|
||||||
const execution = this.getExecution(executionId);
|
this.getExecution(executionId).status = status;
|
||||||
if (execution) {
|
|
||||||
execution.status = status;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getStatus(executionId: string): ExecutionStatus | undefined {
|
getStatus(executionId: string): ExecutionStatus {
|
||||||
return this.getExecution(executionId)?.status;
|
return this.getExecution(executionId).status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Wait for all active executions to finish */
|
/** Wait for all active executions to finish */
|
||||||
|
@ -241,7 +224,7 @@ export class ActiveExecutions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private getExecution(executionId: string): IExecutingWorkflowData | undefined {
|
private getExecution(executionId: string): IExecutingWorkflowData {
|
||||||
const execution = this.activeExecutions[executionId];
|
const execution = this.activeExecutions[executionId];
|
||||||
if (!execution) {
|
if (!execution) {
|
||||||
ErrorReporterProxy.error(new ExecutionNotFoundError(executionId));
|
ErrorReporterProxy.error(new ExecutionNotFoundError(executionId));
|
||||||
|
|
|
@ -334,10 +334,7 @@ export class WorkflowRunner {
|
||||||
if (workflowExecution.isCanceled) {
|
if (workflowExecution.isCanceled) {
|
||||||
fullRunData.finished = false;
|
fullRunData.finished = false;
|
||||||
}
|
}
|
||||||
const status = this.activeExecutions.getStatus(executionId);
|
fullRunData.status = this.activeExecutions.getStatus(executionId);
|
||||||
if (status) {
|
|
||||||
fullRunData.status = status;
|
|
||||||
}
|
|
||||||
this.activeExecutions.finalizeExecution(executionId, fullRunData);
|
this.activeExecutions.finalizeExecution(executionId, fullRunData);
|
||||||
})
|
})
|
||||||
.catch(
|
.catch(
|
||||||
|
|
Loading…
Reference in a new issue