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..fcaec8b29d 100644 --- a/packages/core/src/store.ts +++ b/packages/core/src/store.ts @@ -16135,8 +16135,18 @@ ${stepsSection}`; this._archiveDb = null; } if (this.secretsCentralCore) { - void this.secretsCentralCore.close(); + /** + * FNXC:TaskStoreShutdown 2026-06-29-13:04: + * TaskStore.close() must deterministically await the cached secrets CentralCore close before temp-root cleanup and test teardown continue. + * CentralCore.close() is currently synchronous internally, but awaiting the async contract prevents unhandled rejections and preserves shutdown safety if the central secrets handle gains asynchronous cleanup. + */ + 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) {