fix(editor): Skip orphan pin cleanup when deleted node has no pinned data (no-changelog) (#32098)

Co-authored-by: Claude Opus 4.8 <[email protected]>
This commit is contained in:
Alex Grozav
2026-06-12 10:46:49 +00:00
committed by GitHub
co-authored by Claude Opus 4.8
parent d0be4f7554
commit e6d1ceff69
2 changed files with 17 additions and 1 deletions
@@ -431,6 +431,19 @@ describe('getPinDataSize', () => {
expect(pinData.pinnedDataByNodeName.value.Other).toBeDefined();
});
it('skips cleanup when the deleted node has no pinned data', () => {
const { pinData, fire } = createPinDataWithNodesChange();
pinData.pinNodeData('Other', [{ json: { y: 2 } }] as INodeExecutionData[]);
const hookSpy = vi.fn();
pinData.onPinnedDataChange(hookSpy);
const before = pinData.pinnedDataByNodeName.value;
fire({ action: CHANGE_ACTION.DELETE, payload: { id: 'node-id-1', name: 'Target' } });
expect(hookSpy).not.toHaveBeenCalled();
expect(pinData.pinnedDataByNodeName.value).toBe(before);
});
it('does nothing when DELETE has no node name (removeAllNodes)', () => {
const { pinData, fire } = createPinDataWithNodesChange();
pinData.pinNodeData('Target', [{ json: { x: 1 } }] as INodeExecutionData[]);
@@ -227,7 +227,10 @@ export function useWorkflowDocumentPinData(deps: WorkflowDocumentPinDataDeps) {
// useWorkflowDocumentNodes via an injected `unpinNodeData` dep;
// pulling it into the pinData subscriber means nodes doesn't need
// to know about pinData at all (breaks the construction cycle).
if (payload.name) applyUnpin(payload.name);
// Skipped when the node has no pinned data: unpinning unconditionally
// would replace the pin-data object identity (dirtying every computed
// that reads it) and fire a spurious DELETE pin event.
if (payload.name && pinnedDataByNodeName.value[payload.name]) applyUnpin(payload.name);
break;
}
case CHANGE_ACTION.SET: {