fix: stabilize memory sync progress
This commit is contained in:
@@ -84,12 +84,12 @@ describe("memory manager sync failures", () => {
|
|||||||
// Call the internal scheduler directly; it uses fire-and-forget sync.
|
// Call the internal scheduler directly; it uses fire-and-forget sync.
|
||||||
(manager as unknown as { scheduleWatchSync: () => void }).scheduleWatchSync();
|
(manager as unknown as { scheduleWatchSync: () => void }).scheduleWatchSync();
|
||||||
|
|
||||||
await vi.runAllTimersAsync();
|
await vi.runOnlyPendingTimersAsync();
|
||||||
const syncPromise = syncSpy.mock.results[0]?.value as Promise<void> | undefined;
|
const syncPromise = syncSpy.mock.results[0]?.value as Promise<void> | undefined;
|
||||||
|
vi.useRealTimers();
|
||||||
if (syncPromise) {
|
if (syncPromise) {
|
||||||
await syncPromise.catch(() => undefined);
|
await syncPromise.catch(() => undefined);
|
||||||
}
|
}
|
||||||
await vi.runOnlyPendingTimersAsync();
|
|
||||||
|
|
||||||
process.off("unhandledRejection", handler);
|
process.off("unhandledRejection", handler);
|
||||||
expect(unhandled).toHaveLength(0);
|
expect(unhandled).toHaveLength(0);
|
||||||
|
|||||||
@@ -876,7 +876,9 @@ export class MemoryIndexManager {
|
|||||||
force?: boolean;
|
force?: boolean;
|
||||||
progress?: (update: MemorySyncProgressUpdate) => void;
|
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 vectorReady = await this.ensureVectorReady();
|
||||||
const meta = this.readMeta();
|
const meta = this.readMeta();
|
||||||
const needsFullReindex =
|
const needsFullReindex =
|
||||||
|
|||||||
Reference in New Issue
Block a user