test: close sqlite state handles in gateway suites

This commit is contained in:
Peter Steinberger
2026-05-15 08:28:42 +01:00
parent 63e2571e78
commit 24b2950417
2 changed files with 7 additions and 0 deletions

View File

@@ -35,6 +35,7 @@ import {
} from "../routing/session-key.js";
import { normalizeLowercaseStringOrEmpty } from "../shared/string-coerce.js";
import { normalizeOptionalString } from "../shared/string-coerce.js";
import { closeOpenClawAgentDatabasesForTest } from "../state/openclaw-agent-db.js";
import { closeOpenClawStateDatabaseForTest } from "../state/openclaw-state-db.js";
import { resetTaskRegistryForTests } from "../tasks/runtime-internal.js";
import { resetTaskFlowRegistryForTests } from "../tasks/task-flow-runtime-internal.js";
@@ -241,6 +242,7 @@ async function resetGatewayTestState(options: { uniqueConfigRoot: boolean }) {
delete process.env.OPENCLAW_GATEWAY_TOKEN;
resetTaskRegistryForTests({ persist: false });
resetTaskFlowRegistryForTests({ persist: false });
closeOpenClawAgentDatabasesForTest();
closeOpenClawStateDatabaseForTest();
const stateDir = process.env.OPENCLAW_STATE_DIR;
if (stateDir) {
@@ -352,6 +354,8 @@ async function cleanupGatewayTestHome(options: { restoreEnv: boolean }) {
resetLogger();
resetTaskRegistryForTests({ persist: false });
resetTaskFlowRegistryForTests({ persist: false });
closeOpenClawAgentDatabasesForTest();
closeOpenClawStateDatabaseForTest();
if (options.restoreEnv) {
gatewayEnvSnapshot?.restore();
gatewayEnvSnapshot = undefined;

View File

@@ -8,6 +8,7 @@ import type { OpenClawConfig } from "../src/config/config.js";
import type { OutboundSendDeps } from "../src/infra/outbound/deliver.js";
import type { PluginRegistry } from "../src/plugins/registry.js";
import { closeOpenClawAgentDatabasesForTest } from "../src/state/openclaw-agent-db.js";
import { closeOpenClawStateDatabaseForTest } from "../src/state/openclaw-state-db.js";
import { installSharedTestSetup } from "./setup.shared.js";
installSharedTestSetup();
@@ -363,6 +364,7 @@ afterEach(async () => {
const { resetContextWindowCacheForTest, resetModelCatalogReadyCacheForTest } =
await loadWorkerCleanupHelpers();
closeOpenClawAgentDatabasesForTest();
closeOpenClawStateDatabaseForTest();
resetContextWindowCacheForTest();
resetModelCatalogReadyCacheForTest();
await installDefaultPluginRegistry();
@@ -370,4 +372,5 @@ afterEach(async () => {
afterAll(async () => {
closeOpenClawAgentDatabasesForTest();
closeOpenClawStateDatabaseForTest();
});