Skip to content

Commit f8fc490

Browse files
authored
fix watcher race condition (#56)
* fix watcher race condition. see issue #55 on some sytems the compiler was not readable after chokidar called sendUpdateDiagnostics. Setting "awaitWriteFinish" as an option fixes the issue * decrease chokidar watch treshold to 1ms
1 parent 5caa099 commit f8fc490

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

server/src/server.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,15 @@ let deleteProjectDiagnostics = (projectRootPath: string) => {
105105
}
106106
};
107107

108-
let compilerLogsWatcher = chokidar.watch([]).on("all", (_e, changedPath) => {
109-
sendUpdatedDiagnostics();
110-
});
108+
let compilerLogsWatcher = chokidar
109+
.watch([], {
110+
awaitWriteFinish: {
111+
stabilityThreshold: 1,
112+
},
113+
})
114+
.on("all", (_e, changedPath) => {
115+
sendUpdatedDiagnostics();
116+
});
111117
let stopWatchingCompilerLog = () => {
112118
// TODO: cleanup of compilerLogs?
113119
compilerLogsWatcher.close();

0 commit comments

Comments
 (0)