Files
openclaw/docs/help
Peter Steinberger c07906d5fa fix(test): SQLite teardown fails when a test's agent database close overlaps the next test (#160258)
* fix(test): SQLite teardown fails when a test's agent database close overlaps the next test

Most fixtures tear down with the synchronous closeOpenClawAgentDatabasesForTest(),
which only schedules asynchronous agent-database Worker retirement. A Testbox
sweep of the 308 candidate files that never await the async drain found ~36
whose teardown leaves those closes running into the next test. A reclamation
lease release that overlaps later work and ends unsettled falls back to
cleanup that needs the host SQLite broker, which a Vitest thread never has,
so the runner fails the file and retains SQLite custody for the rest of the
worker (CI run 36290393694).

The shared runner now waits for scheduled agent database closes before each
test (ahead of aroundEach setup), before each retry attempt, and before a
file's cleanup phases. Failure reporting is unchanged: a failed close stays
with its owner and the file-end drain. Child-Vitest fixtures prove the next
test starts only after a scheduled close settled, including after a runtime
skip and around aroundEach setup and teardown.

* test: settle close-ordering fixtures on an event-loop turn

The ordering fixtures used a fixed 100ms timer, which the test policy
disallows and which could let the old runner pass if the inter-test gap
grew. Settle each synthetic close one event-loop turn later instead; the
teardown-to-next-test path is promise-only, so the base runner still
reaches the next test with the close pending (3 of 3 base runs fail,
3 of 3 patched runs pass on Testbox).
2026-09-28 02:05:41 -07:00
..