-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(core): fix lifecycle issue when cancelling manual executions #10789
base: master
Are you sure you want to change the base?
fix(core): fix lifecycle issue when cancelling manual executions #10789
Conversation
@@ -163,6 +175,12 @@ export class ActiveExecutions { | |||
promise.reject(reason); | |||
} | |||
|
|||
// FIXME: Option 2: Don't clean up the execution. Because we cancelled it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function can probably be removed, because cancelling the promises is probably not correct, given that cancelling an execution will still resolve the promise returned from it:
n8n/packages/core/src/WorkflowExecute.ts
Line 857 in d61d563
onCancel.shouldReject = false; |
And in case we want to reject this, then the WorkflowRunner
should do it after the execution promise has been resolved and it checked that it resolved early because it was cancelled.
//} | ||
|
||
// NOTE: new code | ||
// FIXME: Option 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preferred solution. There is only one place that deregisters the execution:
n8n/packages/cli/src/workflow-runner.ts
Line 326 in d61d563
this.activeExecutions.remove(executionId, fullRunData); |
context.onExecutionCancellation(() => { | ||
clearTimeout(timer); | ||
// FIXME: Don't let the promise dangle | ||
resolve([context.getInputData()]); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated and I'll split this out, but left it here for context as to why the wait node is not affected by this.
Summary
The fix in #9992 introduced a lifecycle issue with executions where an execution would be removed multiple times from the
ActiveExecution
s.Normally the flow would be like this:
When cancelling this would happen (unless for the wait node):
Wait Node
The wait node would never resolve, so it would look like this:Before #9992 the flow was like this. And I think it should be like that again.
So while I have 3 solutions in this PR I prefer Option 3, which concentrates the responsibility for registering and unregistering active executions again within the
WorkflowRunner
.Once I've decided on a solution I'll write tests and refactor the rest of the code.
Related Linear tickets, Github issues, and Community forum posts
https://linear.app/n8n/issue/PAY-1554/error-no-active-execution-found
Review / Merge checklist
Docs updated or follow-up ticket created.release/backport
(if the PR is an urgent fix that needs to be backported)