Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions browser_tests/tests/propertiesPanel/errorsTabMissingNodes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}) => {
Expand Down
95 changes: 95 additions & 0 deletions src/scripts/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions src/scripts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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') {
Expand Down Expand Up @@ -2430,7 +2435,8 @@ export class ComfyApp {
const nodeOutputStore = useNodeOutputStore()
nodeOutputStore.resetAllOutputsAndPreviews()
const executionErrorStore = useExecutionErrorStore()
executionErrorStore.clearAllErrors()
executionErrorStore.clearRunErrors()
useMissingNodesErrorStore().setMissingNodeTypes([])

useDomWidgetStore().clear()

Expand Down
23 changes: 12 additions & 11 deletions src/stores/executionErrorStore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -797,7 +796,9 @@ describe('hasMissingError', () => {
{
type: 'nodes',
seedMissingError: () => {
useMissingNodesErrorStore().missingNodesError = fromAny({})
useMissingNodesErrorStore().setMissingNodeTypes([
{ type: 'TestNode', hint: '' }
])
}
},
{
Expand All @@ -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')])
Expand All @@ -832,7 +833,7 @@ describe('hasMissingError', () => {
})
})

describe('clearAllErrors', () => {
describe('clearRunErrors', () => {
let executionErrorStore: ReturnType<typeof useExecutionErrorStore>
let missingNodesStore: ReturnType<typeof useMissingNodesErrorStore>

Expand All @@ -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,
Expand Down Expand Up @@ -873,18 +874,18 @@ describe('clearAllErrors', () => {
class_type: 'Test'
}
})
missingNodesStore.setMissingNodeTypes(
fromAny<MissingNodeType[], unknown>([{ 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)
})
})
12 changes: 5 additions & 7 deletions src/stores/executionErrorStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -550,7 +548,7 @@ export const useExecutionErrorStore = defineStore('executionError', () => {
recordPromptError,

// Clearing
clearAllErrors,
clearRunErrors,
clearExecutionStartErrors,
clearPromptError,

Expand Down
Loading