mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 14:30:41 +00:00
[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:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user