diff --git a/.changeset/thin-rocks-post.md b/.changeset/thin-rocks-post.md new file mode 100644 index 0000000000..7408a397ce --- /dev/null +++ b/.changeset/thin-rocks-post.md @@ -0,0 +1,7 @@ +--- +"@runfusion/fusion": patch +--- + +summary: Wait for task store secret database handles to close before cleanup. +category: fix +dev: Awaits the async secrets store close path during TaskStore shutdown to avoid teardown races. diff --git a/packages/core/src/store.ts b/packages/core/src/store.ts index cc05a95a0c..e3814e957e 100644 --- a/packages/core/src/store.ts +++ b/packages/core/src/store.ts @@ -16135,8 +16135,17 @@ ${stepsSection}`; this._archiveDb = null; } if (this.secretsCentralCore) { - void this.secretsCentralCore.close(); + // Await the secrets central core close: CentralCore.close() is async, so a + // fire-and-forget call would let close() resolve while the secrets SQLite + // handle is still draining on a later microtask, racing temp-root cleanup + // under the loaded package test lane. Await it like the other handles above. + const secretsCentralCore = this.secretsCentralCore; this.secretsCentralCore = null; + try { + await secretsCentralCore.close(); + } catch (err) { + console.warn(`[fusion] Could not close secrets central core on TaskStore close:`, err); + } } this.secretsStore = null; if (this.pluginStore) {