mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-21 05:32:53 +00:00
fix: harden Matrix snapshot lock timing
This commit is contained in:
@@ -1194,7 +1194,9 @@ describe("MatrixClient crypto bootstrapping", () => {
|
||||
const callsAfterStart = databasesSpy.mock.calls.length;
|
||||
|
||||
await vi.advanceTimersByTimeAsync(60_000);
|
||||
expect(databasesSpy.mock.calls.length).toBeGreaterThan(callsAfterStart);
|
||||
await vi.waitFor(() => {
|
||||
expect(databasesSpy.mock.calls.length).toBeGreaterThan(callsAfterStart);
|
||||
});
|
||||
|
||||
client.stop();
|
||||
const callsAfterStop = databasesSpy.mock.calls.length;
|
||||
|
||||
@@ -8,6 +8,9 @@ import { LogService } from "./logger.js";
|
||||
// Advisory lock options for IDB snapshot file access. Without locking, the
|
||||
// gateway's periodic 60-second persist cycle and CLI crypto commands (e.g.
|
||||
// `openclaw matrix verify bootstrap`) can corrupt each other's state.
|
||||
// Use a longer stale window than the generic 30s default because snapshot
|
||||
// restore and large crypto-store dumps can legitimately hold the lock for
|
||||
// longer, and reclaiming a live lock would reintroduce concurrent corruption.
|
||||
const IDB_SNAPSHOT_LOCK_OPTIONS: FileLockOptions = {
|
||||
retries: {
|
||||
retries: 10,
|
||||
@@ -16,7 +19,7 @@ const IDB_SNAPSHOT_LOCK_OPTIONS: FileLockOptions = {
|
||||
maxTimeout: 5_000,
|
||||
randomize: true,
|
||||
},
|
||||
stale: 30_000,
|
||||
stale: 5 * 60_000,
|
||||
};
|
||||
|
||||
type IdbStoreSnapshot = {
|
||||
|
||||
Reference in New Issue
Block a user