Skip to content
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: add error handling and race condition guard to syncNodeImgs
  • Loading branch information
christian-byrne committed Dec 13, 2025
commit 62d278c5e64dcaa90dc0c06279c9de2db88f1b52
11 changes: 11 additions & 0 deletions src/stores/imagePreviewStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const useNodeOutputStore = defineStore('nodeOutput', () => {
const { executionIdToNodeLocatorId } = useExecutionStore()
const scheduledRevoke: Record<NodeLocatorId, { stop: () => void }> = {}
const latestOutput = ref<string[]>([])
const nodeLoadIds = new WeakMap<LGraphNode, number>()

function scheduleRevoke(locator: NodeLocatorId, cb: () => void) {
scheduledRevoke[locator]?.stop()
Expand Down Expand Up @@ -174,11 +175,21 @@ export const useNodeOutputStore = defineStore('nodeOutput', () => {
const node = app.canvas?.graph?.getNodeById(nodeId)
if (!node) return

const loadId = (nodeLoadIds.get(node) ?? 0) + 1
nodeLoadIds.set(node, loadId)

const img = new Image()
img.onload = () => {
if (nodeLoadIds.get(node) !== loadId) return
node.imgs = [img]
node.imageIndex = 0
}
img.onerror = () => {
if (nodeLoadIds.get(node) !== loadId) return
node.imgs = []
node.imageIndex = 0
console.warn(`[ImagePreview] Failed to load image for node ${nodeId}`)
}
img.src = imageUrls[0]
}

Expand Down
Loading