fix(storage): the flush watcher cannot arm twice in its async window
Arming is asynchronous — the request directory is created before it can be watched — so during that window neither the watcher nor the sweep interval exists yet and the guard let a second call through, leaving two watchers and two sweeps for the life of the store. The callback is the flag that covers the window.
This commit is contained in:
parent
258176e6e6
commit
f52053a3d3
1 changed files with 6 additions and 1 deletions
|
|
@ -2432,7 +2432,12 @@ export class FileSystemStorage extends BaseStorage {
|
|||
* an inspector whose request is never seen waits forever.
|
||||
*/
|
||||
public override startFlushRequestWatcher(onRequest: () => Promise<void>): void {
|
||||
if (this.flushWatcherInterval || this.flushWatcher) return // already watching
|
||||
// Already watching — or already ARMING. The arm is asynchronous (the
|
||||
// request directory is created before it can be watched), so neither the
|
||||
// watcher nor the interval exists yet during that window; the callback is
|
||||
// the flag that covers it. Without this a second call in the window would
|
||||
// leave two watchers and two sweeps running for the life of the store.
|
||||
if (this.flushWatcherInterval || this.flushWatcher || this.flushWatcherOnRequest) return
|
||||
this.flushWatcherOnRequest = onRequest
|
||||
|
||||
const reqDir = path.join(this.lockDir, FileSystemStorage.FLUSH_REQUEST_DIR)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue