diff --git a/src/tasks/task-flow-registry.ts b/src/tasks/task-flow-registry.ts index 27e8900888d..4f5777cc620 100644 --- a/src/tasks/task-flow-registry.ts +++ b/src/tasks/task-flow-registry.ts @@ -710,6 +710,6 @@ export function resetTaskFlowRegistryForTests(opts?: { persist?: boolean }) { resetTaskFlowRegistryRuntimeForTests(); if (opts?.persist !== false) { persistFlowRegistry(); - getTaskFlowRegistryStore().close?.(); } + getTaskFlowRegistryStore().close?.(); } diff --git a/src/tasks/task-registry.ts b/src/tasks/task-registry.ts index 45877ad44ec..d265ff8e204 100644 --- a/src/tasks/task-registry.ts +++ b/src/tasks/task-registry.ts @@ -1927,10 +1927,10 @@ export function resetTaskRegistryForTests(opts?: { persist?: boolean }) { listenerStarted = false; if (opts?.persist !== false) { persistTaskRegistry(); - // Close the sqlite handle after persisting the empty snapshot so Windows temp-dir - // cleanup can remove the state directory without hitting runs.sqlite EBUSY errors. - getTaskRegistryStore().close?.(); } + // Always close the sqlite handle so Windows temp-dir cleanup can remove the + // state directory even when a test intentionally skips persisting the reset. + getTaskRegistryStore().close?.(); } export function resetTaskRegistryDeliveryRuntimeForTests() {