[backport cloud/1.42] fix: prevent blueprint cache corruption on repeated placement (#10460)

Backport of #9897 to `cloud/1.42`

Automatically created by backport workflow.

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-10460-backport-cloud-1-42-fix-prevent-blueprint-cache-corruption-on-repeated-placement-32d6d73d36508131aec3c65bd5d53c9e)
by [Unito](https://www.unito.io)

Co-authored-by: Christian Byrne <cbyrne@comfy.org>
This commit is contained in:
Comfy Org PR Bot
2026-03-25 09:12:34 +09:00
committed by GitHub
parent c789897e36
commit 60dc9797e8
2 changed files with 11 additions and 1 deletions

View File

@@ -155,6 +155,16 @@ describe('useSubgraphStore', () => {
} as ComfyNodeDefV1)
expect(res).toBeTruthy()
})
it('should return a deep copy from getBlueprint so mutations do not corrupt the cache', async () => {
await mockFetch({ 'test.json': mockGraph })
const first = store.getBlueprint(store.typePrefix + 'test')
first.nodes[0].id = -1
first.definitions!.subgraphs![0].id = 'corrupted'
const second = store.getBlueprint(store.typePrefix + 'test')
expect(second.nodes[0].id).not.toBe(-1)
expect(second.definitions!.subgraphs![0].id).toBe('123')
})
it('should identify user blueprints as non-global', async () => {
await mockFetch({ 'test.json': mockGraph })
expect(store.isGlobalBlueprint('test')).toBe(false)

View File

@@ -392,7 +392,7 @@ export const useSubgraphStore = defineStore('subgraph', () => {
if (!(name in subgraphCache))
//As loading is blocked on in startup, this can likely be changed to invalid type
throw new Error('not yet loaded')
return subgraphCache[name].changeTracker.initialState
return structuredClone(subgraphCache[name].changeTracker.initialState)
}
async function deleteBlueprint(nodeType: string) {
const name = nodeType.slice(typePrefix.length)