-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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
refactor(core): Streamline flows in multi-main mode (no-changelog) #8446
Conversation
packages/cli/src/services/orchestration/main/handle-workflow-updated.ts
Outdated
Show resolved
Hide resolved
2 flaky tests on run #3979 ↗︎Details:
|
Test | Artifacts | |
---|---|---|
NDV > should not retrieve remote options when required params throw errors |
Test Replay
Screenshots
Video
|
19-execution.cy.ts • 1 flaky test
Test | Artifacts | |
---|---|---|
Execution > should test manual workflow stop |
Test Replay
Screenshots
Video
|
Review all test suite changes for PR #8446 ↗︎
✅ All Cypress E2E specs passed |
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.
I'm loving to see the progress.
Left a comment about console messages and noticed something a bit odd - if I click the toggle to deactivate a workflow on a follower, the main won't reflect the deactivation in the UI, when I have the same workflow open in both leader and follower.
|
||
const shouldAddWebhooks = this.orchestrationService.shouldAddWebhooks(activationMode); | ||
const shouldAddTriggersAndPollers = this.orchestrationService.shouldAddTriggersAndPollers(); | ||
|
||
const shouldActivate = shouldAddWebhooks || shouldAddTriggersAndPollers; |
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 should check be shouldDisplayActivationMessages
and be based on whether activationMode === 'init'
instead.
The result we're getting now is that whenever i disable and enable a workflow I get the messages on the current leader and I'm almost sure we used to display those messages only on init.
|
||
if (typeof workflowId !== 'string') break; | ||
|
||
push.broadcast('workflowActivated', { workflowId }); |
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.
Just to be sure, the UI is ready to only display this if the currently open workflow ID matches to the one sent in the payload right?
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.
The FE at pushConnection.ts
receives this workflow ID and calls store methods:
if (receivedData.type === 'workflowActivated') {
this.workflowsStore.setWorkflowActive(receivedData.data.workflowId);
return true;
}
if (receivedData.type === 'workflowDeactivated') {
this.workflowsStore.setWorkflowInactive(receivedData.data.workflowId);
return true;
}
And the store methods compare the pushed workflow ID against this.workflow.id
, which as far as I understand is the workflow on canvas.
setWorkflowActive(workflowId: string): void {
const uiStore = useUIStore();
uiStore.stateIsDirty = false;
const index = this.activeWorkflows.indexOf(workflowId);
if (index === -1) {
this.activeWorkflows.push(workflowId);
}
if (this.workflowsById[workflowId]) {
this.workflowsById[workflowId].active = true;
}
if (workflowId === this.workflow.id) {
this.setActive(true);
}
},
setWorkflowInactive(workflowId: string): void {
const index = this.activeWorkflows.indexOf(workflowId);
if (index !== -1) {
this.activeWorkflows.splice(index, 1);
}
if (this.workflowsById[workflowId]) {
this.workflowsById[workflowId].active = false;
}
if (workflowId === this.workflow.id) {
this.setActive(false);
}
},
Got released with |
* refactor(core): Replace promisify-d node calls with native promises (no-changelog) (n8n-io#8464) * fix(editor): Send template id as a number in telemetry events (n8n-io#8484) * refactor(editor): Prevent router.replace from computed property (no-changelog) (n8n-io#8489) Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * feat(core): Remove `own` execution-process mode (n8n-io#8490) * feat(editor): Implement loading and error states for dynamically loaded components in node parameter list (n8n-io#8477) * fix(AwsS3 Node): Fix handling of bucket with dot in name (n8n-io#8475) * refactor(core): Modernize credentials controllers and services (no-changelog) (n8n-io#8488) Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in> * fix(core): Don't report executions that have been paused as failed to rudderstack and log streams (n8n-io#8501) * fix: Properly iterate over credentials with expressions (n8n-io#8502) * refactor(core): Move all code related to `onServerStarted` into `InternalHooks` (no-changelog) (n8n-io#8500) * feat(editor): Send template id as string in all telemetry events (n8n-io#8498) * fix(core): Handle possibly invalid `updatedAt` timestamps in source-control (n8n-io#8485) * fix(core): Forward authorization header when on same domain (n8n-io#8507) * fix(core): Improve handling of wrapped errors (n8n-io#8510) * 🚀 Release 1.27.0 (n8n-io#8512) Co-authored-by: ivov <ivov@users.noreply.github.com> * ci: Skip running `postInstall` scripts for all packages except sqlite3 (no-changelog) (n8n-io#8514) * ci: Fix DB tests (no-changelog) (n8n-io#8513) * fix(core): Fix new graceful shutdown env being always overridden by deprecated env (n8n-io#8503) * fix(HTTP Request Node): Support form data when using pagination (n8n-io#8497) * fix(HTTP Request Node): Require parameter with filled name and value to avoid infinite loop (n8n-io#8454) Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <netroy@users.noreply.github.com> Co-authored-by: Elias Meire <elias@meire.dev> * fix(Microsoft Excel 365 Node): Upsert append new rows at the end of used range, option to append at the end of selected range (n8n-io#8461) * fix(Slack Node): Attachments fix (n8n-io#8471) Co-authored-by: Elias Meire <elias@meire.dev> * feat: Azure Open AI chat model & embeddings (n8n-io#8522) Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * fix(core): Fix test runs of triggers that rely on static data (n8n-io#8524) * ci: Replace `pnpm/action-setup` action with corepack (no-changelog) (n8n-io#8504) * fix(MongoDB Node): Fix "Maximum call stack size exceeded" error on too many rows (n8n-io#8530) * fix: Allow Date/Luxon objects and additional formats in DateTime validation (n8n-io#8525) * fix(editor): Prune values that are not in the schema in the ResourceMapper component (n8n-io#8478) * fix(core): Fix PermissionChecker.check, and add additional unit tests (n8n-io#8528) * fix(core): Fix DropRoleMapping migration (n8n-io#8521) * fix(core): Ensure AxiosError status always gets copied over to NodeApiError (n8n-io#8509) * fix(Embeddings OpenAI Node): Fix dynamic models fetching (n8n-io#8533) Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * fix(core): Fix workflow tagging failure due to unique constraint check (n8n-io#8505) * ci: Fix release-create-pr.yml (no-changelog) * fix(core): Upgrade nodemailer to address an exploit (n8n-io#8535) * feat(RabbitMQ Trigger Node): Add options to configure assert of exchanges and queues (n8n-io#8430) * feat(editor): Add delete and disable button to nodes on hover (n8n-io#8482) * feat(Email Trigger (IMAP) Node): Upgrade mailparser (n8n-io#8539) * refactor(core): Streamline flows in multi-main mode (no-changelog) (n8n-io#8446) * fix: Remove ts-node from overrides and typeorm script (no-changelog) (n8n-io#8547) * fix: Update BaseChatModel import checks for MistralAI compatibility (n8n-io#8527) Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * docs: Add encryption key check to breaking changes list (n8n-io#8551) * refactor(core): Lock `webhook` process out of multi-main setup (no-changelog) (n8n-io#8549) * refactor(core): Continue breaking dependency cycles (no-changelog) (n8n-io#8545) * fix(core): Use trx manager instead of repository for tags overwrite (n8n-io#8557) * build: Fix outdated import to fix build (no-changelog) (n8n-io#8558) * refactor(core): Couple of refactors on WorkflowRunner and ActiveExecutions (no-changelog) (n8n-io#8487) * feat: Add assignment component with drag and drop to Set node (n8n-io#8283) Co-authored-by: Giulio Andreini <andreini@netseven.it> * ci: Update validate-n8n-pull-request-title action (no-changelog) (n8n-io#8553) * fix(core): Use hostname from URL instead of Host header for SNI (n8n-io#8562) * fix(Microsoft Outlook Node): Download executes more than once per incoming item (n8n-io#8566) * 🚀 Release 1.28.0 (n8n-io#8569) Co-authored-by: ivov <ivov@users.noreply.github.com> * ci(core): Avoid slow bcrypt calls in tests (no-changelog) (n8n-io#8570) * fix(core): Upgrade rudderstack sdk to address npm postInstall issues (n8n-io#8568) * feat: Upgrade typeorm, sqlite3, and pg/pg-promise (n8n-io#8579) * build: Add GitHub issue form for reporting bugs (n8n-io#8585) * fix(Google Sheets Trigger Node): First non-header row is ignored when using on row added event (n8n-io#8580) * fix(RSS Feed Trigger Node): Save last item's date instead of last execution date (n8n-io#8572) * feat(core): Migrate to n8n's typeorm fork (n8n-io#8590) * refactor: Add lint rule for unsafe property access with lodash get/set (no-changelog) (n8n-io#8587) * fix(HTTP Request Node): Errorneous binary object without content-disposition response header (n8n-io#8583) Co-authored-by: Marcus <marcus@n8n.io> * fix(core): Custom workflow tool tweaks (n8n-io#8561) * Fixes imports and enables workers view --------- Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <netroy@users.noreply.github.com> Co-authored-by: Milorad FIlipović <milorad@n8n.io> Co-authored-by: oleg <me@olegivaniv.com> Co-authored-by: Iván Ovejero <ivov.src@gmail.com> Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in> Co-authored-by: Danny Martini <despair.blue@gmail.com> Co-authored-by: Omar Ajoue <krynble@gmail.com> Co-authored-by: Elias Meire <elias@meire.dev> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: ivov <ivov@users.noreply.github.com> Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com> Co-authored-by: Andrea Ascari <dev.ascariandrea@gmail.com> Co-authored-by: Giulio Andreini <andreini@netseven.it> Co-authored-by: Cornelius Suermann <cornelius@n8n.io> Co-authored-by: Bruno Inec <contact@sweenu.xyz> Co-authored-by: Marcus <marcus@n8n.io>
* Andy/joy 277 mergeupdate n8n 128 (#54) * refactor(core): Replace promisify-d node calls with native promises (no-changelog) (n8n-io#8464) * fix(editor): Send template id as a number in telemetry events (n8n-io#8484) * refactor(editor): Prevent router.replace from computed property (no-changelog) (n8n-io#8489) Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * feat(core): Remove `own` execution-process mode (n8n-io#8490) * feat(editor): Implement loading and error states for dynamically loaded components in node parameter list (n8n-io#8477) * fix(AwsS3 Node): Fix handling of bucket with dot in name (n8n-io#8475) * refactor(core): Modernize credentials controllers and services (no-changelog) (n8n-io#8488) Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in> * fix(core): Don't report executions that have been paused as failed to rudderstack and log streams (n8n-io#8501) * fix: Properly iterate over credentials with expressions (n8n-io#8502) * refactor(core): Move all code related to `onServerStarted` into `InternalHooks` (no-changelog) (n8n-io#8500) * feat(editor): Send template id as string in all telemetry events (n8n-io#8498) * fix(core): Handle possibly invalid `updatedAt` timestamps in source-control (n8n-io#8485) * fix(core): Forward authorization header when on same domain (n8n-io#8507) * fix(core): Improve handling of wrapped errors (n8n-io#8510) * 🚀 Release 1.27.0 (n8n-io#8512) Co-authored-by: ivov <ivov@users.noreply.github.com> * ci: Skip running `postInstall` scripts for all packages except sqlite3 (no-changelog) (n8n-io#8514) * ci: Fix DB tests (no-changelog) (n8n-io#8513) * fix(core): Fix new graceful shutdown env being always overridden by deprecated env (n8n-io#8503) * fix(HTTP Request Node): Support form data when using pagination (n8n-io#8497) * fix(HTTP Request Node): Require parameter with filled name and value to avoid infinite loop (n8n-io#8454) Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <netroy@users.noreply.github.com> Co-authored-by: Elias Meire <elias@meire.dev> * fix(Microsoft Excel 365 Node): Upsert append new rows at the end of used range, option to append at the end of selected range (n8n-io#8461) * fix(Slack Node): Attachments fix (n8n-io#8471) Co-authored-by: Elias Meire <elias@meire.dev> * feat: Azure Open AI chat model & embeddings (n8n-io#8522) Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * fix(core): Fix test runs of triggers that rely on static data (n8n-io#8524) * ci: Replace `pnpm/action-setup` action with corepack (no-changelog) (n8n-io#8504) * fix(MongoDB Node): Fix "Maximum call stack size exceeded" error on too many rows (n8n-io#8530) * fix: Allow Date/Luxon objects and additional formats in DateTime validation (n8n-io#8525) * fix(editor): Prune values that are not in the schema in the ResourceMapper component (n8n-io#8478) * fix(core): Fix PermissionChecker.check, and add additional unit tests (n8n-io#8528) * fix(core): Fix DropRoleMapping migration (n8n-io#8521) * fix(core): Ensure AxiosError status always gets copied over to NodeApiError (n8n-io#8509) * fix(Embeddings OpenAI Node): Fix dynamic models fetching (n8n-io#8533) Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * fix(core): Fix workflow tagging failure due to unique constraint check (n8n-io#8505) * ci: Fix release-create-pr.yml (no-changelog) * fix(core): Upgrade nodemailer to address an exploit (n8n-io#8535) * feat(RabbitMQ Trigger Node): Add options to configure assert of exchanges and queues (n8n-io#8430) * feat(editor): Add delete and disable button to nodes on hover (n8n-io#8482) * feat(Email Trigger (IMAP) Node): Upgrade mailparser (n8n-io#8539) * refactor(core): Streamline flows in multi-main mode (no-changelog) (n8n-io#8446) * fix: Remove ts-node from overrides and typeorm script (no-changelog) (n8n-io#8547) * fix: Update BaseChatModel import checks for MistralAI compatibility (n8n-io#8527) Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * docs: Add encryption key check to breaking changes list (n8n-io#8551) * refactor(core): Lock `webhook` process out of multi-main setup (no-changelog) (n8n-io#8549) * refactor(core): Continue breaking dependency cycles (no-changelog) (n8n-io#8545) * fix(core): Use trx manager instead of repository for tags overwrite (n8n-io#8557) * build: Fix outdated import to fix build (no-changelog) (n8n-io#8558) * refactor(core): Couple of refactors on WorkflowRunner and ActiveExecutions (no-changelog) (n8n-io#8487) * feat: Add assignment component with drag and drop to Set node (n8n-io#8283) Co-authored-by: Giulio Andreini <andreini@netseven.it> * ci: Update validate-n8n-pull-request-title action (no-changelog) (n8n-io#8553) * fix(core): Use hostname from URL instead of Host header for SNI (n8n-io#8562) * fix(Microsoft Outlook Node): Download executes more than once per incoming item (n8n-io#8566) * 🚀 Release 1.28.0 (n8n-io#8569) Co-authored-by: ivov <ivov@users.noreply.github.com> * ci(core): Avoid slow bcrypt calls in tests (no-changelog) (n8n-io#8570) * fix(core): Upgrade rudderstack sdk to address npm postInstall issues (n8n-io#8568) * feat: Upgrade typeorm, sqlite3, and pg/pg-promise (n8n-io#8579) * build: Add GitHub issue form for reporting bugs (n8n-io#8585) * fix(Google Sheets Trigger Node): First non-header row is ignored when using on row added event (n8n-io#8580) * fix(RSS Feed Trigger Node): Save last item's date instead of last execution date (n8n-io#8572) * feat(core): Migrate to n8n's typeorm fork (n8n-io#8590) * refactor: Add lint rule for unsafe property access with lodash get/set (no-changelog) (n8n-io#8587) * fix(HTTP Request Node): Errorneous binary object without content-disposition response header (n8n-io#8583) Co-authored-by: Marcus <marcus@n8n.io> * fix(core): Custom workflow tool tweaks (n8n-io#8561) * Fixes imports and enables workers view --------- Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <netroy@users.noreply.github.com> Co-authored-by: Milorad FIlipović <milorad@n8n.io> Co-authored-by: oleg <me@olegivaniv.com> Co-authored-by: Iván Ovejero <ivov.src@gmail.com> Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in> Co-authored-by: Danny Martini <despair.blue@gmail.com> Co-authored-by: Omar Ajoue <krynble@gmail.com> Co-authored-by: Elias Meire <elias@meire.dev> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: ivov <ivov@users.noreply.github.com> Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com> Co-authored-by: Andrea Ascari <dev.ascariandrea@gmail.com> Co-authored-by: Giulio Andreini <andreini@netseven.it> Co-authored-by: Cornelius Suermann <cornelius@n8n.io> Co-authored-by: Bruno Inec <contact@sweenu.xyz> Co-authored-by: Marcus <marcus@n8n.io> * Enables advanced permissions * Fixes workflow statistics update errors --------- Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <netroy@users.noreply.github.com> Co-authored-by: Milorad FIlipović <milorad@n8n.io> Co-authored-by: oleg <me@olegivaniv.com> Co-authored-by: Iván Ovejero <ivov.src@gmail.com> Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in> Co-authored-by: Danny Martini <despair.blue@gmail.com> Co-authored-by: Omar Ajoue <krynble@gmail.com> Co-authored-by: Elias Meire <elias@meire.dev> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: ivov <ivov@users.noreply.github.com> Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com> Co-authored-by: Andrea Ascari <dev.ascariandrea@gmail.com> Co-authored-by: Giulio Andreini <andreini@netseven.it> Co-authored-by: Cornelius Suermann <cornelius@n8n.io> Co-authored-by: Bruno Inec <contact@sweenu.xyz> Co-authored-by: Marcus <marcus@n8n.io>
Summary
This PR brings multi-main mode in line with our current understanding of the best approach to handle all n8n flows relevant to multi-main mode.
Details
On instance startup (single- or multi-main mode)
active
in the database and adds triggers and pollers for active workflows, but it does not add webhooks for active workflows, because we no longer deregister webhooks on shutdown. The main instance also starts pruning.On leader stepdown (only multi-main mode)
On leader takeover (only multi-main mode)
config.set('multiMainSetup.instanceType', 'leader')
. In reaction to this event, the new leader behaves exactly like the leader on instance startup.On workflow update (single- or multi-main mode)
webhook_entity
table, and deregistering them from external services.Notes on workflow update flow and its subflows:
active
state in the database back tofalse
, informs all its connected FEs of the activation failure, and sends a message to all other main instances, which react by also informing all their connected FEs of the activation failure. This update in reaction to an activation failure does not rely onversionId
because there is no user intervention. Activation failure state resides in Redis and therefore is available to all connected FEs.On test webhook (single- or multi-main mode)
Workflow.testStaticData
property to make test static data available to nodes. Then, when the single main instance receives a webhook from the external service, it executes the workflow, pushes execution lifecycle events to the FE, deregisters the test webhook from the external service, removes the test webhook from the cache, and pushes the final execution lifecycle event to the FE.Workflow.testStaticData
if needed), removes the test webhook from the cache, and relays the final execution lifecycle event to all other main instances. Of the recipient main instances, the one having the session ID where the webhook was created pushes the final execution lifecycle event to the FE.Manual testing
Single-main regular mode
active
totrue
in the database, and start instance.)Multi-main queue mode