From 0ca0e5c6cc31774db66abdf0f5ff192bdf39f166 Mon Sep 17 00:00:00 2001 From: David Snelling Date: Tue, 16 Jun 2026 13:18:14 -0700 Subject: [PATCH] test(8.0): close brains in afterEach (count-sync, get-relations teardown) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both suites removed their test directory without closing the brain, leaving the writer-lock heartbeat + flush timers running into teardown and the next test. Adds brain.close() before the rm. Remaining failures in these files are separate, deeper issues (tracked in .strategy): get-relations has one pagination assertion; count-sync is off-by-one because a fresh brain carries one system/VFS-root noun that counts in totalNounCount while find() excludes it — a counts-semantics decision. --- tests/integration/count-synchronization.test.ts | 8 ++++++++ tests/integration/get-relations-fix.test.ts | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/tests/integration/count-synchronization.test.ts b/tests/integration/count-synchronization.test.ts index 8e6d19f8..6923ab6d 100644 --- a/tests/integration/count-synchronization.test.ts +++ b/tests/integration/count-synchronization.test.ts @@ -34,6 +34,14 @@ describe('Count Synchronization (Bug Fix v4.1.2)', () => { }) afterEach(async () => { + // Close the brain first so its writer-lock heartbeat + flush timers stop + // before the directory is removed — otherwise they race teardown and bleed + // state into the next test. + try { + await brain?.close() + } catch { + // Best-effort teardown. + } // Clean up test directory try { await fs.rm(testPath, { recursive: true, force: true }) diff --git a/tests/integration/get-relations-fix.test.ts b/tests/integration/get-relations-fix.test.ts index 71efad6f..451e34a0 100644 --- a/tests/integration/get-relations-fix.test.ts +++ b/tests/integration/get-relations-fix.test.ts @@ -33,6 +33,14 @@ describe('related() call patterns', () => { }) afterEach(async () => { + // Close the brain first so its writer-lock heartbeat + flush timers stop + // before the directory is removed — otherwise they race teardown and bleed + // state into the next test. + try { + await brain?.close() + } catch { + // Best-effort teardown. + } // Clean up test directory try { await fs.rm(testPath, { recursive: true, force: true })