Skip to content
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): Do not execute workflowExecuteBefore hook when resuming executions from a waiting state #5727

Merged
merged 2 commits into from
Apr 6, 2023

Conversation

netroy
Copy link
Member

@netroy netroy commented Mar 20, 2023

Fixes CP-344

@netroy netroy changed the title fix(core): So not execute workflowExecuteBefore hook when resuming executions from a waiting state fix(core): Do not execute workflowExecuteBefore hook when resuming executions from a waiting state Mar 20, 2023
@github-actions
Copy link
Contributor

Great PR! Please pay attention to the following items before merging:

Files matching packages/**:

  • If fixing bug, added test to cover scenario.
  • If addressing forum or Github issue, added link to description.

Files matching packages/**/*.ts:

  • Added unit tests to cover new or updated functionality.

Make sure to check off this list before asking for review.

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Mar 20, 2023
@@ -746,7 +746,10 @@ export class WorkflowExecute {

const returnPromise = (async () => {
try {
await this.executeHook('workflowExecuteBefore', [workflow]);
const { executionId, restartExecutionId } = this.additionalData;
if (restartExecutionId !== executionId) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it enough to simply check if restartExecutionId is not undefined?

krynble
krynble previously approved these changes Mar 20, 2023
Copy link
Contributor

@krynble krynble left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Ideally we would place it in WorkflowExecuteAdditionalData but there is some context missing there, so this is the place.

Copy link
Member Author

@netroy netroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized that this also skips the workflowExecuteBefore hook that sends the executionStarted push message to the frontend.
But, since when the execution resumes, no sessionId is getting passed down to that hook, which is also skiping sending the push message.

@krynble Should we move the restartExecutionId to the WorkflowHooks class instead?
We'd still need to fix the issue of the missing sessionId, but that can be a separate PR.

@netroy netroy force-pushed the CP-344-skip-preexecute-hook-on-resume branch 2 times, most recently from 056f853 to 2c4fc6b Compare April 5, 2023 16:12
@codecov
Copy link

codecov bot commented Apr 5, 2023

Codecov Report

Patch coverage: 40.00% and no project coverage change.

Comparison is base (dba5be3) 17.52% compared to head (2c4fc6b) 17.52%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5727   +/-   ##
=======================================
  Coverage   17.52%   17.52%           
=======================================
  Files        2495     2495           
  Lines      114289   114293    +4     
  Branches    17852    17853    +1     
=======================================
+ Hits        20027    20028    +1     
- Misses      93671    93674    +3     
  Partials      591      591           
Impacted Files Coverage Δ
packages/cli/src/WorkflowRunner.ts 9.85% <0.00%> (-0.08%) ⬇️
packages/cli/src/WorkflowRunnerProcess.ts 0.00% <0.00%> (ø)
packages/workflow/src/Interfaces.ts 50.00% <ø> (ø)
packages/core/src/WorkflowExecute.ts 49.35% <100.00%> (+0.13%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@netroy netroy requested a review from krynble April 5, 2023 16:35
netroy

This comment was marked as resolved.

Copy link
Contributor

@krynble krynble left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@netroy netroy merged commit 6689451 into master Apr 6, 2023
@netroy netroy deleted the CP-344-skip-preexecute-hook-on-resume branch April 6, 2023 08:18
@janober
Copy link
Member

janober commented Apr 19, 2023

Got released with [email protected]

sunilrr pushed a commit to fl-g6/qp-n8n that referenced this pull request Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team Released skip-e2e
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants