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): Don't execute 'workflowExecuteBefore' hook on execution continuations #9905

Conversation

despairblue
Copy link
Contributor

@despairblue despairblue commented Jul 1, 2024

Summary

Since version 1.29.0 n8n executes the workflow.preExecute hook whenever an execution transitions from waiting to running.
workflow.preExecute should only be called once per execution.

This was introduced by a combination of #8487 and #8601.
The former refactored the WorkflowRunner class. It passes the executionId to runMainProcess, in the position where the restartExecutionId is expected.
This leads eventually to this code never executing:

if (!this.additionalData.restartExecutionId) {
await this.executeHook('workflowExecuteBefore', [workflow]);
}

The latter PR attempted to fix this by calling additionalData.hooks.executeHookFunctions('workflowExecuteBefore', []); directly in runMainProcess.

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/PAY-1712/executions-counted-multiple-times-if-there-is-a-wait-node-on-cloud

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Jul 1, 2024
@despairblue despairblue added the release/backport Changes that need to be backported to older releases. label Jul 8, 2024
@despairblue despairblue marked this pull request as ready for review July 8, 2024 16:54
@despairblue despairblue requested a review from valya July 8, 2024 16:54
@despairblue
Copy link
Contributor Author

@valya I created a follow up issue to eventually write a regression test for this: https://linear.app/n8n/issue/PAY-1726/add-regression-test-for-workflow-execution-hooks

Copy link
Contributor

github-actions bot commented Jul 9, 2024

⚠️ Some Cypress E2E specs are failing, please fix them before merging

Copy link

cypress bot commented Jul 9, 2024

4 flaky tests on run #5848 ↗︎

0 399 0 0 Flakiness 4

Details:

🌳 🖥️ browsers:node18.12.0-chrome107 🤖 despairblue 🗃️ e2e/*
Project: n8n Commit: cf7cae4302
Status: Passed Duration: 05:07 💡
Started: Jul 9, 2024 1:01 PM Ended: Jul 9, 2024 1:06 PM
Flakiness  5-ndv.cy.ts • 2 flaky tests

View Output Video

Test Artifacts
NDV > should not retrieve remote options when required params throw errors Screenshots Video
NDV > Stop listening for trigger event from NDV Screenshots Video
Flakiness  10-undo-redo.cy.ts • 2 flaky tests

View Output Video

Test Artifacts
Undo/Redo > should undo/redo adding nodes Test Replay Screenshots Video
Undo/Redo > should undo/redo adding connected nodes Test Replay Screenshots Video

Review all test suite changes for PR #9905 ↗︎

@despairblue despairblue force-pushed the pay-1712-executions-counted-multiple-times-if-there-is-a-wait-node-on branch from 6f6d79b to cf7cae4 Compare July 9, 2024 12:19
@despairblue despairblue requested a review from valya July 9, 2024 12:48
Copy link
Contributor

github-actions bot commented Jul 9, 2024

✅ All Cypress E2E specs passed

@despairblue despairblue merged commit adb8315 into master Jul 9, 2024
27 checks passed
@despairblue despairblue deleted the pay-1712-executions-counted-multiple-times-if-there-is-a-wait-node-on branch July 9, 2024 13:11
@janober
Copy link
Member

janober commented Jul 10, 2024

Got released with n8n@1.50.0

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 release/backport Changes that need to be backported to older releases. Released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants