From a37e5026fc099da98d082bf3cbc748fc0aa6fa2f Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Wed, 30 Sep 2026 23:36:43 -0700 Subject: [PATCH] test(native-chat): cancel the journal import test's tick before teardown (#24071) The test re-arms a setImmediate tick while the copy runs and stopped it with a flag. A tick already queued when the import resolved still ran, and when the afterEach teardown closed the database first it threw journal_closed as an unhandled error, failing a CI shard with every test green. Clear the queued tick instead. --- .../journal-per-session-import.test.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/native-chat/agent-session-journal/journal-per-session-import.test.ts b/src/main/native-chat/agent-session-journal/journal-per-session-import.test.ts index ea28ba4ef83..c9737bf2007 100644 --- a/src/main/native-chat/agent-session-journal/journal-per-session-import.test.ts +++ b/src/main/native-chat/agent-session-journal/journal-per-session-import.test.ts @@ -331,23 +331,21 @@ describe('importing a per-chat journal', () => { }) ) const between: number[] = [] - let copying = true const tick = (): void => { // What a live chat's append would commit under, between two copy batches. between.push(synchronous()) - if (copying) { - setImmediate(tick) - } + pending = setImmediate(tick) } - setImmediate(tick) + let pending = setImmediate(tick) await importPerSessionJournal({ database, identity: IDENTITY, legacyDirectory: legacyDir(), batchRows: 1 }) - copying = false + // A flag would still let the queued tick read the database after teardown closes it. + clearImmediate(pending) // 2 is FULL, 1 is NORMAL. expect(commits.slice(0, rows.length)).toEqual(rows.map(() => 1))