fix: stabilize memory sync progress

This commit is contained in:
Peter Steinberger
2026-01-17 23:01:03 +00:00
parent 82b7153ac1
commit 852aa16ca0
2 changed files with 5 additions and 3 deletions

View File

@@ -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<void> | undefined;
vi.useRealTimers();
if (syncPromise) {
await syncPromise.catch(() => undefined);
}
await vi.runOnlyPendingTimersAsync();
process.off("unhandledRejection", handler);
expect(unhandled).toHaveLength(0);

View File

@@ -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 =