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): Handle ghost nodes/connections gracefully #13840

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

netroy
Copy link
Member

@netroy netroy commented Mar 11, 2025

Summary

There is a bug in the new canvas that doesn't delete all connections when a node is deleted.
This leads to the workflows on the backend that have ghost nodes, which leads to unexpected behavior.
This PR fixes the issue on the backend to handle such workflows that have already been saved to the DB.
We still need to create a fix for the frontend to cleanup connections properly when a node is deleted.

To reproduce the bug

  1. add a manual-trigger node
  2. add a merge node with both inputs connected to the manual-trigger node
  3. delete the merge node
  4. try executing just the manual-trigger node

on master the execution should fail with an unhandled error, and on this branch, the execution should go through without any issues.

Related Linear tickets, Github issues, and Community forum posts

Fixes #13086

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)

@netroy netroy force-pushed the handle-phantom-nodes branch from 6556f5e to 1926752 Compare March 11, 2025 17:21
@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Mar 11, 2025
Copy link
Contributor

@despairblue despairblue left a comment

Choose a reason for hiding this comment

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

One suggestion and one question, looks good otherwise 👏🏾

for (const inputConnections of Object.values(returnConnection[sourceNode])) {
inputConnections.forEach((innerConnections, index) => {
if (innerConnections?.length) {
inputConnections[index] = innerConnections?.filter(({ node }) => node in this.nodes);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
inputConnections[index] = innerConnections?.filter(({ node }) => node in this.nodes);
inputConnections[index] = innerConnections.filter(({ node }) => node in this.nodes);

Already proved above.

Comment on lines +280 to +281
const connectionsByDestinationNode = computed(
() => cachedWorkflow?.connectionsByDestinationNode ?? {},
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this related?

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

Successfully merging this pull request may close these issues.

"Cannot read properties of undefined" in no operation node
2 participants