From a71f4c936e2c98bb7e6d51a339ef2164ab537ec3 Mon Sep 17 00:00:00 2001 From: jaeone lee <89377375+jaeone94@users.noreply.github.com> Date: Sun, 16 Aug 2026 06:13:00 +0000 Subject: [PATCH] fix(errors): keep missing node packs across prompt submissions (#14900) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Pressing Run emptied the missing-node-pack rows from the Errors tab; the nodes were still missing, the panel just stopped saying so. ## Changes - **What**: `clearAllErrors` was shared by `queuePrompt` ("forget the last run") and `clean()` ("forget this graph"), and cleared missing-node state for both. A submission carries no evidence about the environment — it never checks whether the pack was installed — so it cannot justify dropping the row. The clear moves to `clean()`, and the function is renamed `clearRunErrors` to match what it now does. Missing **model** and **media** state already followed this rule: `clearAllErrors` never touched it, and it is cleared in `loadGraphData` instead. This aligns missing nodes with the two resources that were already right; it does not change when models or media are cleared. Production change is four lines. ## Review Focus **Every discard path still clears.** `clean()` is reached by `loadGraphData`, `loadApiJson`, `Comfy.ClearWorkflow` (`useCoreCommands.ts:279`) and the legacy Clear button (`ui.ts:680`). **Except one, which needed the clear spelled out.** The A1111 import replaces the graph from inside `importA1111` through a `beforeGraphClear` callback and never reaches `clean()`, so it already left the store describing the outgoing graph. That was survivable only because the next submission happened to wipe it — with submissions no longer clearing, the stale rows would persist indefinitely. `afterLoadNewGraph` does not call `showPendingWarnings`, so nothing else re-syncs that path. The callback runs after the parameters and required core nodes validate, so a failed import keeps the current state. **What this deliberately does not do.** An earlier version of this PR generalised the same rule to the missing-model and missing-media stores. It was abandoned: those two carry async verification that outlives the graph that started it, plus a per-workflow cache and a two-tier repair state, and unifying them produced five separate defects (cache resurrection after discard, cache not synced on per-node removal, verification not aborted, an abort whose signal was passed but never checked after the await, and the A1111 bypass for all three resources). None of that is in this PR. It is written up separately and will be its own change. ## Verification Four tests, each mutation-proved — revert the production line, watch the named test fail, restore, watch it pass: | mutation | fails | |---|---| | restore the clear inside `clearRunErrors` | `preserves missing node packs when submitting a prompt`, store test, E2E | | drop `clean()`'s clear | `clears missing node packs when the graph is discarded` | | drop the A1111 callback clear | `clears missing node packs, which its graph swap skips clean() for` | | drop `queuePrompt`'s `clearRunErrors()` | queue unit test | The E2E (`errorsTabMissingNodes.spec.ts`) waits on the `POST /api/prompt` response before re-asserting, so it observes the state after the submit path has run rather than racing it. `pnpm typecheck`, `pnpm typecheck:browser`, `pnpm lint` (0 errors), `pnpm knip`, `pnpm format` all clean; 88 unit tests and the E2E pass. Replaces #14557. --- .../errorsTabMissingNodes.spec.ts | 26 +++++ src/scripts/app.test.ts | 95 +++++++++++++++++++ src/scripts/app.ts | 12 ++- src/stores/executionErrorStore.test.ts | 23 ++--- src/stores/executionErrorStore.ts | 12 +-- 5 files changed, 147 insertions(+), 21 deletions(-) diff --git a/browser_tests/tests/propertiesPanel/errorsTabMissingNodes.spec.ts b/browser_tests/tests/propertiesPanel/errorsTabMissingNodes.spec.ts index 62ddaa0c9a9..e5a106d3bf4 100644 --- a/browser_tests/tests/propertiesPanel/errorsTabMissingNodes.spec.ts +++ b/browser_tests/tests/propertiesPanel/errorsTabMissingNodes.spec.ts @@ -30,6 +30,32 @@ test.describe('Errors tab - Missing nodes', { tag: ['@ui', '@canvas'] }, () => { ).toHaveText(/\S/) }) + test('Should keep the missing node pack card after submitting a prompt', async ({ + comfyPage + }) => { + test.info().annotations.push({ + type: 'regression', + description: + 'Submitting a prompt cleared missing-node state, emptying the Errors tab' + }) + + await loadWorkflowAndOpenErrorsTab(comfyPage, 'missing/missing_nodes') + + const missingNodeCard = comfyPage.page.getByTestId( + TestIds.dialogs.missingNodeCard + ) + await expect(missingNodeCard).toBeVisible() + + const prompted = comfyPage.page.waitForResponse((response) => + response.url().includes('/api/prompt') + ) + await comfyPage.runButton.click() + await prompted + + await expect(missingNodeCard).toBeVisible() + await expect(missingNodeCard.getByText('Unknown pack')).toBeVisible() + }) + test('Should show unknown pack node rows by default', async ({ comfyPage }) => { diff --git a/src/scripts/app.test.ts b/src/scripts/app.test.ts index 134c28fec6e..32685607755 100644 --- a/src/scripts/app.test.ts +++ b/src/scripts/app.test.ts @@ -312,6 +312,34 @@ describe('ComfyApp', () => { vi.spyOn(api, 'dispatchCustomEvent').mockImplementation(() => true) } + it('preserves missing node packs when submitting a prompt', async () => { + prepareEmptyPromptQueue() + const missingNodesStore = useMissingNodesErrorStore() + const executionErrorStore = useExecutionErrorStore() + missingNodesStore.setMissingNodeTypes(['test/UninstalledLiveNode']) + executionErrorStore.recordExecutionError({ + prompt_id: 'previous-run', + timestamp: 0, + node_id: '1', + node_type: 'Test', + executed: [], + exception_message: 'fail', + exception_type: 'RuntimeError', + traceback: [] + }) + vi.spyOn(api, 'queuePrompt').mockResolvedValue({ + prompt_id: 'job-1', + error: '' + }) + + await app.queuePrompt(0) + + expect(missingNodesStore.missingNodesError?.nodeTypes).toEqual([ + 'test/UninstalledLiveNode' + ]) + expect(executionErrorStore.lastExecutionError).toBeNull() + }) + it('shows the error overlay for successful prompt responses with node errors', async () => { const graph = new LGraph() const workflow = new ComfyWorkflow({ @@ -1036,6 +1064,73 @@ describe('ComfyApp', () => { ]) }) }) + describe('A1111 import', () => { + it('clears missing node packs, which its graph swap skips clean() for', async () => { + const graph = new LGraph() + Reflect.set(app, 'rootGraphInternal', graph) + const missingNodesStore = useMissingNodesErrorStore() + missingNodesStore.setMissingNodeTypes(['OutgoingMissingNode']) + vi.mocked(getWorkflowDataFromFile).mockResolvedValue({ + parameters: 'positive\nNegative prompt: negative\nSteps: 20' + }) + mockImportA1111.mockImplementation( + async (_graph, _parameters, beforeGraphClear) => { + beforeGraphClear?.() + return 'imported' + } + ) + + await app.handleFile(createTestFile('a1111.png', 'image/png')) + + expect(missingNodesStore.missingNodesError).toBeNull() + }) + + it.for(['not-a1111', 'core-nodes-unavailable'] as const)( + 'keeps missing node packs when the import fails with %s', + async (outcome) => { + const graph = new LGraph() + Reflect.set(app, 'rootGraphInternal', graph) + const missingNodesStore = useMissingNodesErrorStore() + missingNodesStore.setMissingNodeTypes(['OutgoingMissingNode']) + vi.mocked(getWorkflowDataFromFile).mockResolvedValue({ + parameters: 'positive\nNegative prompt: negative\nSteps: 20' + }) + mockImportA1111.mockResolvedValue(outcome) + + await app.handleFile(createTestFile('a1111.png', 'image/png')) + + expect(missingNodesStore.missingNodesError?.nodeTypes).toEqual([ + 'OutgoingMissingNode' + ]) + } + ) + }) + + describe('clean', () => { + it('clears missing node packs when the graph is discarded', () => { + const graph = new LGraph() + Reflect.set(app, 'rootGraphInternal', graph) + const missingNodesStore = useMissingNodesErrorStore() + const executionErrorStore = useExecutionErrorStore() + missingNodesStore.setMissingNodeTypes(['MissingGroupNode']) + executionErrorStore.recordExecutionError({ + prompt_id: 'previous-run', + timestamp: 0, + node_id: '1', + node_type: 'Test', + executed: [], + exception_message: 'fail', + exception_type: 'RuntimeError', + traceback: [] + }) + + app.clean() + + expect(missingNodesStore.missingNodesError).toBeNull() + expect(executionErrorStore.lastExecutionError).toBeNull() + }) + }) + describe('refreshComboInNodes', () => { it('shows success toast and removes the pending toast after node defs reload', async () => { app.vueAppReady = true diff --git a/src/scripts/app.ts b/src/scripts/app.ts index c71c185db83..9731e1d59b2 100644 --- a/src/scripts/app.ts +++ b/src/scripts/app.ts @@ -113,6 +113,7 @@ import { normalizePromptError } from '@/utils/executionErrorUtil' import { graphToPrompt } from '@/utils/executionUtil' import { parseJsonWithNonFinite } from '@/utils/jsonUtil' import { getCnrIdFromProperties } from '@/platform/nodeReplacement/cnrIdUtil' +import { useMissingNodesErrorStore } from '@/platform/nodeReplacement/missingNodesErrorStore' import { rescanAndSurfaceMissingNodes } from '@/platform/nodeReplacement/missingNodeScan' import { refreshMissingModelPipeline, @@ -1645,7 +1646,7 @@ export class ComfyApp { const executionStore = useExecutionStore() const executionErrorStore = useExecutionErrorStore() const telemetry = useTelemetry() - executionErrorStore.clearAllErrors() + executionErrorStore.clearRunErrors() let queueResultOverride: boolean | null = null // Get auth token for backend nodes - uses workspace token if enabled, otherwise Firebase token @@ -2019,7 +2020,11 @@ export class ComfyApp { // Use parameters strictly as the final fallback if (parameters && typeof parameters === 'string') { const outcome = await importA1111(this.rootGraph, parameters, () => { - useWorkflowService().beforeLoadNewGraph() + try { + useWorkflowService().beforeLoadNewGraph() + } finally { + useMissingNodesErrorStore().setMissingNodeTypes([]) + } this.canvas.setGraph(this.rootGraph) }) if (outcome === 'core-nodes-unavailable') { @@ -2430,7 +2435,8 @@ export class ComfyApp { const nodeOutputStore = useNodeOutputStore() nodeOutputStore.resetAllOutputsAndPreviews() const executionErrorStore = useExecutionErrorStore() - executionErrorStore.clearAllErrors() + executionErrorStore.clearRunErrors() + useMissingNodesErrorStore().setMissingNodeTypes([]) useDomWidgetStore().clear() diff --git a/src/stores/executionErrorStore.test.ts b/src/stores/executionErrorStore.test.ts index 220a23cb69e..e66e028c19b 100644 --- a/src/stores/executionErrorStore.test.ts +++ b/src/stores/executionErrorStore.test.ts @@ -3,7 +3,6 @@ import { createPinia, setActivePinia } from 'pinia' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { nodeError, validationError } from '@/utils/__tests__/nodeErrorHelpers' -import type { MissingNodeType } from '@/types/comfy' import { createBoundaryLinkedSubgraph, createTestRootGraph, @@ -797,7 +796,9 @@ describe('hasMissingError', () => { { type: 'nodes', seedMissingError: () => { - useMissingNodesErrorStore().missingNodesError = fromAny({}) + useMissingNodesErrorStore().setMissingNodeTypes([ + { type: 'TestNode', hint: '' } + ]) } }, { @@ -822,7 +823,7 @@ describe('hasMissingError', () => { expect(executionErrorStore.hasMissingError).toBe(true) }) - it('excludes node validation errors', () => { + it('returns false when only node validation errors exist', () => { const executionErrorStore = useExecutionErrorStore() executionErrorStore.recordNodeErrors({ '1': nodeError([validationError('required_input_missing', 'input')]) @@ -832,7 +833,7 @@ describe('hasMissingError', () => { }) }) -describe('clearAllErrors', () => { +describe('clearRunErrors', () => { let executionErrorStore: ReturnType let missingNodesStore: ReturnType @@ -843,7 +844,7 @@ describe('clearAllErrors', () => { missingNodesStore = useMissingNodesErrorStore() }) - it('resets all error categories and closes error overlay', () => { + it('resets run errors and closes the overlay, leaving missing resources', () => { executionErrorStore.recordExecutionError({ prompt_id: 'test', timestamp: 0, @@ -873,18 +874,18 @@ describe('clearAllErrors', () => { class_type: 'Test' } }) - missingNodesStore.setMissingNodeTypes( - fromAny([{ type: 'MissingNode', hint: '' }]) - ) + missingNodesStore.setMissingNodeTypes([{ type: 'MissingNode', hint: '' }]) executionErrorStore.showErrorOverlay() - executionErrorStore.clearAllErrors() + executionErrorStore.clearRunErrors() expect(executionErrorStore.lastExecutionError).toBeNull() expect(executionErrorStore.lastPromptError).toBeNull() expect(executionErrorStore.lastNodeErrors).toBeNull() - expect(missingNodesStore.missingNodesError).toBeNull() expect(executionErrorStore.isErrorOverlayOpen).toBe(false) - expect(executionErrorStore.hasAnyError).toBe(false) + expect(missingNodesStore.missingNodesError?.nodeTypes).toEqual([ + { type: 'MissingNode', hint: '' } + ]) + expect(executionErrorStore.hasAnyError).toBe(true) }) }) diff --git a/src/stores/executionErrorStore.ts b/src/stores/executionErrorStore.ts index 920d6c962f2..ac790a813fc 100644 --- a/src/stores/executionErrorStore.ts +++ b/src/stores/executionErrorStore.ts @@ -83,15 +83,13 @@ export const useExecutionErrorStore = defineStore('executionError', () => { isErrorOverlayOpen.value = false } - /** Clear all error state. - * Missing model state is intentionally preserved here to avoid wiping - * in-progress model repairs (importTaskIds, URL inputs, etc.). - * Missing models are cleared separately during workflow load/clean paths. */ - function clearAllErrors() { + /** Clear error state produced by a run. Missing-resource state describes the + * loaded graph rather than the run, so only replacing or discarding the + * graph invalidates it. */ + function clearRunErrors() { lastExecutionError.value = null lastPromptError.value = null lastNodeErrors.value = null - missingNodesStore.setMissingNodeTypes([]) isErrorOverlayOpen.value = false } @@ -550,7 +548,7 @@ export const useExecutionErrorStore = defineStore('executionError', () => { recordPromptError, // Clearing - clearAllErrors, + clearRunErrors, clearExecutionStartErrors, clearPromptError,