mirror of
https://fastgit.cc/github.com/openclaw/openclaw
synced 2026-04-30 22:12:32 +08:00
matrix: stabilize healthy sync epochs
This commit is contained in:
@@ -523,7 +523,16 @@ describe("monitorMatrixProvider", () => {
|
||||
expect(getHealthySyncSinceMs()).toBeUndefined();
|
||||
|
||||
hoisted.client.emit("sync.state", "SYNCING", "RECONNECTING", undefined);
|
||||
expect(getHealthySyncSinceMs()).toBe(Date.now());
|
||||
const firstHealthySyncSinceMs = Date.now();
|
||||
expect(getHealthySyncSinceMs()).toBe(firstHealthySyncSinceMs);
|
||||
|
||||
await vi.advanceTimersByTimeAsync(3_000);
|
||||
hoisted.client.emit("sync.state", "CATCHUP", "SYNCING", undefined);
|
||||
expect(getHealthySyncSinceMs()).toBe(firstHealthySyncSinceMs);
|
||||
|
||||
await vi.advanceTimersByTimeAsync(2_000);
|
||||
hoisted.client.emit("sync.state", "PREPARED", "CATCHUP", undefined);
|
||||
expect(getHealthySyncSinceMs()).toBe(firstHealthySyncSinceMs);
|
||||
|
||||
await vi.advanceTimersByTimeAsync(5_000);
|
||||
hoisted.client.emit("sync.state", "RECONNECTING", "SYNCING", new Error("network flap"));
|
||||
|
||||
@@ -250,7 +250,7 @@ export async function monitorMatrixProvider(opts: MonitorMatrixOpts = {}): Promi
|
||||
let healthySyncSinceMs: number | undefined;
|
||||
const noteSyncHealthState = (state: MatrixSyncState, at = Date.now()) => {
|
||||
if (isMatrixReadySyncState(state)) {
|
||||
healthySyncSinceMs = at;
|
||||
healthySyncSinceMs ??= at;
|
||||
return;
|
||||
}
|
||||
if (isMatrixDisconnectedSyncState(state)) {
|
||||
|
||||
Reference in New Issue
Block a user