mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Add back system watcher limit
This commit is contained in:
+8
-1
@@ -1266,6 +1266,7 @@ namespace ts {
|
||||
let activeSession: import("inspector").Session | "stopping" | undefined;
|
||||
let profilePath = "./profile.cpuprofile";
|
||||
|
||||
let hitSystemWatcherLimit = false;
|
||||
|
||||
const Buffer: {
|
||||
new (input: string, encoding?: string): any;
|
||||
@@ -1619,6 +1620,11 @@ namespace ts {
|
||||
options = { persistent: true };
|
||||
}
|
||||
}
|
||||
|
||||
if (hitSystemWatcherLimit) {
|
||||
sysLog(`sysLog:: ${fileOrDirectory}:: Defaulting to fsWatchFile`);
|
||||
return watchPresentFileSystemEntryWithFsWatchFile();
|
||||
}
|
||||
try {
|
||||
const presentWatcher = _fs.watch(
|
||||
fileOrDirectory,
|
||||
@@ -1635,6 +1641,8 @@ namespace ts {
|
||||
// Catch the exception and use polling instead
|
||||
// Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
|
||||
// so instead of throwing error, use fs.watchFile
|
||||
hitSystemWatcherLimit ||= e.code === "ENOSPC";
|
||||
sysLog(`sysLog:: ${fileOrDirectory}:: Changing to fsWatchFile`);
|
||||
return watchPresentFileSystemEntryWithFsWatchFile();
|
||||
}
|
||||
}
|
||||
@@ -1656,7 +1664,6 @@ namespace ts {
|
||||
* Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
|
||||
*/
|
||||
function watchPresentFileSystemEntryWithFsWatchFile(): FileWatcher {
|
||||
sysLog(`sysLog:: ${fileOrDirectory}:: Changing to fsWatchFile`);
|
||||
return watchFile(
|
||||
fileOrDirectory,
|
||||
createFileWatcherCallback(callback),
|
||||
|
||||
Reference in New Issue
Block a user