Skip to content

Sweep the destinations the trigger provisions during a live run - #27

Merged
leggetter merged 1 commit into
mainfrom
fix/orphaned-destinations
Sep 9, 2026
Merged

leggetter merged 1 commit into
mainfrom
fix/orphaned-destinations

Conversation

@leggetter

Copy link
Copy Markdown
Contributor

Closes #13, for the half of it the evidence supports.

cleanUpRun matched three name shapes; the trigger creates a fourth. Destinations are named n8n-dest-<workflowId>-<nodeId>, the live contexts set the workflow id to the run id, and nothing in the filter started with n8n-dest-. Every destination a live run provisioned survived the sweep — one run measured destinations going 27 → 39 while sources and connections stayed level.

Same miss the function's own comment already records for connections. It went unnoticed longer because the failure is quieter: a leaked connection blocks its source from being deleted and the run reports it, while a leaked destination blocks nothing and just accumulates.

Why the node itself is untouched

#13 is titled as a user-facing leak. Reading it against the code, the measured evidence points the other way:

  • The delete path in webhookMethods.default.delete genuinely does orphan the destination. That's real.
  • But the 49 came from a development project that also runs this suite, and the two the issue samples are type=CLI destinations whose connections were already gone. CLI test registrations are disabled, not deleted — so the node's delete path did not orphan those. This did.
  • Deleting the destination alongside the connection has side effects worth discussing rather than assuming: destinations can be shared, and the current behaviour is deliberate — the teardown comment already argues the case for the source.

Tracked separately for that discussion. pause and disable are correct as they stand; the connection survives, so its destination must too.

The guard

Every accepted shape carries the run id, which is what makes widening safe — the project under test also holds production sources, and a shape without a run id would start deleting them.

ownedByThisRun is exported so the test builds names with the node's own buildResourceName instead of repeating string literals: renaming a resource now fails the test rather than quietly un-sweeping it. Verified by removing the fix — the test fails with cleanup would miss n8n-dest-<run>-nodeid.

Verification

115 unit tests, lint, scan. No CHANGELOG entry: nothing here ships, since files is an allowlist of dist/nodes and dist/credentials.

`cleanUpRun` matched three name shapes and the trigger creates a fourth.
Destinations are named `n8n-dest-<workflowId>-<nodeId>`, the live contexts set
the workflow id to the run id, and nothing in the filter started with
`n8n-dest-`. So every destination a live run provisioned survived the sweep. One
run measured 27 destinations going to 39 while sources and connections stayed
level.

This is the same miss the function's own comment already records for
connections, and it went unnoticed for longer because the failure is quieter: a
leaked connection blocks its source from being deleted and the run reports it,
while a leaked destination blocks nothing and simply accumulates. The 49
orphans in #13 came from a development project that also runs this suite, and
the two it sampled were CLI destinations whose connections were already gone —
which is this, not the node.

The new shape carries the run id like the other three. That is the property that
makes the guard safe to widen: the project under test also holds production
sources, and a shape without a run id would start deleting them.

`ownedByThisRun` is exported so a unit test can build the names with the node's
own `buildResourceName` rather than repeating string literals, which means
renaming a resource fails the test instead of quietly un-sweeping it. Confirmed
by removing the fix: the test fails with `cleanup would miss
n8n-dest-<run>-nodeid`.

Nothing here ships — `files` is an allowlist of `dist/nodes` and
`dist/credentials` — so no CHANGELOG entry.

The node side is deliberately not touched. Deleting the destination when the
connection is deleted is a real code path that orphans, but nothing in the
measured 49 shows a user reaching it, and it is currently by design: the
teardown comment already argues the case for the source. Tracked separately for
the discussion it needs.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U6ZF876ibkomShmV6rSKLn
@leggetter
leggetter merged commit c07980e into main Sep 9, 2026
3 checks passed
@leggetter
leggetter deleted the fix/orphaned-destinations branch September 9, 2026 19:57
@leggetter leggetter mentioned this pull request Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trigger never deletes the destination it provisions — 49 orphaned in 9 days

1 participant