Enable awaitWriteFinish for the db config file watcher (#1872)

This commit is contained in:
Charis Kyriakou
2022-12-14 15:25:34 +00:00
committed by GitHub
parent 602289eb6d
commit b1bf82d432

View File

@@ -166,9 +166,20 @@ export class DbConfigStore extends DisposableObject {
}
private watchConfig(): void {
this.configWatcher = chokidar.watch(this.configPath).on("change", () => {
this.readConfigSync();
});
this.configWatcher = chokidar
.watch(this.configPath, {
// In some cases, change events are emitted while the file is still
// being written. The awaitWriteFinish option tells the watcher to
// poll the file size, holding its add and change events until the size
// does not change for a configurable amount of time. We set that time
// to 1 second, but it may need to be adjusted if there are issues.
awaitWriteFinish: {
stabilityThreshold: 1000,
},
})
.on("change", () => {
this.readConfigSync();
});
}
private createEmptyConfig(): DbConfig {