From 5c22f9500ce9628e7652613babefb00e094adedd Mon Sep 17 00:00:00 2001 From: David Snelling Date: Fri, 28 Aug 2026 11:31:57 -0700 Subject: [PATCH] fix(storage): a dead flush watch falls back to the 500ms poll, not the 30s sweep MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The safety sweep is armed alongside the watch, and startFlushRequestPolling() declines to arm over an existing interval — so when a watch died mid-life the fallback did nothing and the store quietly answered flush requests on a 30s cadence instead of the 500ms one the door promises. The sweep is cleared first. A degrade nobody asked for is still a degrade. --- src/storage/adapters/fileSystemStorage.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/storage/adapters/fileSystemStorage.ts b/src/storage/adapters/fileSystemStorage.ts index fa0715df..5ec1d88e 100644 --- a/src/storage/adapters/fileSystemStorage.ts +++ b/src/storage/adapters/fileSystemStorage.ts @@ -2467,6 +2467,15 @@ export class FileSystemStorage extends BaseStorage { ) this.flushWatcher?.close() this.flushWatcher = undefined + // The SAFETY sweep must go first. It is already armed at 30s, and + // startFlushRequestPolling() declines to arm over an existing + // interval — so leaving it would quietly leave this store answering + // flush requests on a 30s cadence instead of the 500ms one the door + // promises. A degrade nobody asked for is still a degrade. + if (this.flushWatcherInterval) { + clearInterval(this.flushWatcherInterval) + this.flushWatcherInterval = undefined + } this.startFlushRequestPolling(sweep) }) if (typeof watcher.unref === 'function') watcher.unref()