From 852aa16ca0241be08d833ba55742ad48de43f570 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 17 Jan 2026 23:01:03 +0000 Subject: [PATCH] fix: stabilize memory sync progress --- src/memory/manager.sync-errors-do-not-crash.test.ts | 4 ++-- src/memory/manager.ts | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/memory/manager.sync-errors-do-not-crash.test.ts b/src/memory/manager.sync-errors-do-not-crash.test.ts index f07b275ce..3a7ef54e1 100644 --- a/src/memory/manager.sync-errors-do-not-crash.test.ts +++ b/src/memory/manager.sync-errors-do-not-crash.test.ts @@ -84,12 +84,12 @@ describe("memory manager sync failures", () => { // Call the internal scheduler directly; it uses fire-and-forget sync. (manager as unknown as { scheduleWatchSync: () => void }).scheduleWatchSync(); - await vi.runAllTimersAsync(); + await vi.runOnlyPendingTimersAsync(); const syncPromise = syncSpy.mock.results[0]?.value as Promise | undefined; + vi.useRealTimers(); if (syncPromise) { await syncPromise.catch(() => undefined); } - await vi.runOnlyPendingTimersAsync(); process.off("unhandledRejection", handler); expect(unhandled).toHaveLength(0); diff --git a/src/memory/manager.ts b/src/memory/manager.ts index 303e57136..0da3242e3 100644 --- a/src/memory/manager.ts +++ b/src/memory/manager.ts @@ -876,7 +876,9 @@ export class MemoryIndexManager { force?: boolean; progress?: (update: MemorySyncProgressUpdate) => void; }) { - const progress = params?.progress ? this.createSyncProgress(params.progress) : null; + const progress = params?.progress + ? this.createSyncProgress(params.progress) + : undefined; const vectorReady = await this.ensureVectorReady(); const meta = this.readMeta(); const needsFullReindex =