Skip to content

fix(core): Ensure queue is ready when enqueueing #16098

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

Merged
merged 3 commits into from
Jun 10, 2025

Conversation

ivov
Copy link
Contributor

@ivov ivov commented Jun 6, 2025

Summary

There are edge cases where WorkflowRunner attempts to enqueue before the queue is ready. For legacy reasons ScalingService is being dynamically imported in multiple spots, so this is a risk and appears to be related to workers enqueuing executions of error-handling workflows, but I have not been able to reproduce the edge case locally.

This PR ensures the queue is ready when enqueuing. The root solution would be to modularize scaling mode and remove its multiple dynamic imports, and so that all code paths relying on scaling mode are guaranteed that scaling mode init is complete. Adi made an attempt at #11278 but was not satisfied.

Let's fix this now for the time being and work towards modularizing scaling mode when time allows.

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/CAT-784
Fix #15233

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)

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

cubic found 1 issue across 3 files. Review it in cubic.dev

React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.

@ivov ivov requested a review from afitzek June 6, 2025 14:13
Copy link

codecov bot commented Jun 6, 2025

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/cli/src/scaling/scaling.service.ts 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Jun 6, 2025
@checkblue
Copy link

@ivov I frequently encounter this situation. To reproduce it, concurrent task execution is needed, and errors occur frequently under such conditions.

@ivov ivov requested a review from afitzek June 10, 2025 07:36
Copy link
Contributor

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

Copy link
Contributor

✅ All Cypress E2E specs passed

@ivov ivov merged commit 25567f6 into master Jun 10, 2025
51 of 53 checks passed
@ivov ivov deleted the ensure-queue-is-ready-when-enqueuing branch June 10, 2025 08:09
@janober
Copy link
Member

janober commented Jun 11, 2025

Got released with [email protected]

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug] Error workflow fails with "Cannot read properties of undefined (reading 'add')" in Queue Mode
4 participants