MCPcopy Create free account
hub / github.com/arctic-cli/interface / dispose

Function dispose

packages/arctic/src/project/state.ts:31–64  ·  view source on GitHub ↗
(key: string)

Source from the content-addressed store, hash-verified

29 }
30
31 export async function dispose(key: string) {
32 const entries = recordsByKey.get(key)
33 if (!entries) return
34
35 log.info("waiting for state disposal to complete", { key })
36
37 let disposalFinished = false
38
39 setTimeout(() => {
40 if (!disposalFinished) {
41 log.warn(
42 "state disposal is taking an unusually long time - if it does not complete in a reasonable time, please report this as a bug",
43 { key },
44 )
45 }
46 }, 10000).unref()
47
48 const tasks: Promise<void>[] = []
49 for (const entry of entries.values()) {
50 if (!entry.dispose) continue
51
52 const task = Promise.resolve(entry.state)
53 .then((state) => entry.dispose!(state))
54 .catch((error) => {
55 log.error("Error while disposing state:", { error, key })
56 })
57
58 tasks.push(task)
59 }
60 entries.clear()
61 await Promise.all(tasks)
62 disposalFinished = true
63 log.info("state disposal completed", { key })
64 }
65}

Callers 2

DiffFunction · 0.50
DiffFunction · 0.50

Calls 3

pushMethod · 0.80
getMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected