diff --git a/src/stores/imagePreviewStore.ts b/src/stores/imagePreviewStore.ts index 44d84d100..b984151f9 100644 --- a/src/stores/imagePreviewStore.ts +++ b/src/stores/imagePreviewStore.ts @@ -43,6 +43,7 @@ export const useNodeOutputStore = defineStore('nodeOutput', () => { const { executionIdToNodeLocatorId } = useExecutionStore() const scheduledRevoke: Record void }> = {} const latestOutput = ref([]) + const nodeLoadIds = new WeakMap() function scheduleRevoke(locator: NodeLocatorId, cb: () => void) { scheduledRevoke[locator]?.stop() @@ -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] }