Skip to content

Commit f1a20b3

Browse files
committed
Revert "Reduce exceptions (microsoft#44710)"
This reverts commit c0d5c29.
1 parent afef282 commit f1a20b3

File tree

5 files changed

+7
-17
lines changed

5 files changed

+7
-17
lines changed

src/compiler/sys.ts

+2-10
Original file line numberDiff line numberDiff line change
@@ -1266,7 +1266,6 @@ namespace ts {
12661266
let activeSession: import("inspector").Session | "stopping" | undefined;
12671267
let profilePath = "./profile.cpuprofile";
12681268

1269-
let hitSystemWatcherLimit = false;
12701269

12711270
const Buffer: {
12721271
new (input: string, encoding?: string): any;
@@ -1620,12 +1619,6 @@ namespace ts {
16201619
options = { persistent: true };
16211620
}
16221621
}
1623-
1624-
if (hitSystemWatcherLimit) {
1625-
sysLog(`sysLog:: ${fileOrDirectory}:: Defaulting to fsWatchFile`);
1626-
return watchPresentFileSystemEntryWithFsWatchFile();
1627-
}
1628-
16291622
try {
16301623
const presentWatcher = _fs.watch(
16311624
fileOrDirectory,
@@ -1642,8 +1635,6 @@ namespace ts {
16421635
// Catch the exception and use polling instead
16431636
// 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
16441637
// so instead of throwing error, use fs.watchFile
1645-
hitSystemWatcherLimit ||= e.code === "ENOSPC";
1646-
sysLog(`sysLog:: ${fileOrDirectory}:: Changing to fsWatchFile`);
16471638
return watchPresentFileSystemEntryWithFsWatchFile();
16481639
}
16491640
}
@@ -1665,6 +1656,7 @@ namespace ts {
16651656
* 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
16661657
*/
16671658
function watchPresentFileSystemEntryWithFsWatchFile(): FileWatcher {
1659+
sysLog(`sysLog:: ${fileOrDirectory}:: Changing to fsWatchFile`);
16681660
return watchFile(
16691661
fileOrDirectory,
16701662
createFileWatcherCallback(callback),
@@ -1804,7 +1796,7 @@ namespace ts {
18041796
}
18051797

18061798
function readDirectory(path: string, extensions?: readonly string[], excludes?: readonly string[], includes?: readonly string[], depth?: number): string[] {
1807-
return matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), depth, getAccessibleFileSystemEntries, realpath, directoryExists);
1799+
return matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), depth, getAccessibleFileSystemEntries, realpath);
18081800
}
18091801

18101802
function fileSystemEntryExists(path: string, entryKind: FileSystemEntryKind): boolean {

src/compiler/utilities.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -6638,7 +6638,7 @@ namespace ts {
66386638
}
66396639

66406640
/** @param path directory of the tsconfig.json */
6641-
export function matchFiles(path: string, extensions: readonly string[] | undefined, excludes: readonly string[] | undefined, includes: readonly string[] | undefined, useCaseSensitiveFileNames: boolean, currentDirectory: string, depth: number | undefined, getFileSystemEntries: (path: string) => FileSystemEntries, realpath: (path: string) => string, directoryExists: (path: string) => boolean): string[] {
6641+
export function matchFiles(path: string, extensions: readonly string[] | undefined, excludes: readonly string[] | undefined, includes: readonly string[] | undefined, useCaseSensitiveFileNames: boolean, currentDirectory: string, depth: number | undefined, getFileSystemEntries: (path: string) => FileSystemEntries, realpath: (path: string) => string): string[] {
66426642
path = normalizePath(path);
66436643
currentDirectory = normalizePath(currentDirectory);
66446644

@@ -6654,9 +6654,7 @@ namespace ts {
66546654
const visited = new Map<string, true>();
66556655
const toCanonical = createGetCanonicalFileName(useCaseSensitiveFileNames);
66566656
for (const basePath of patterns.basePaths) {
6657-
if (directoryExists(basePath)) {
6658-
visitDirectory(basePath, combinePaths(currentDirectory, basePath), depth);
6659-
}
6657+
visitDirectory(basePath, combinePaths(currentDirectory, basePath), depth);
66606658
}
66616659

66626660
return flatten(results);

src/compiler/watchUtilities.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ namespace ts {
184184
const rootResult = tryReadDirectory(rootDir, rootDirPath);
185185
let rootSymLinkResult: FileSystemEntries | undefined;
186186
if (rootResult !== undefined) {
187-
return matchFiles(rootDir, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath, directoryExists);
187+
return matchFiles(rootDir, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath);
188188
}
189189
return host.readDirectory!(rootDir, extensions, excludes, includes, depth);
190190

src/harness/fakesHosts.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ namespace fakes {
9595
}
9696

9797
public readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[] {
98-
return ts.matchFiles(path, extensions, exclude, include, this.useCaseSensitiveFileNames, this.getCurrentDirectory(), depth, path => this.getAccessibleFileSystemEntries(path), path => this.realpath(path), path => this.directoryExists(path));
98+
return ts.matchFiles(path, extensions, exclude, include, this.useCaseSensitiveFileNames, this.getCurrentDirectory(), depth, path => this.getAccessibleFileSystemEntries(path), path => this.realpath(path));
9999
}
100100

101101
public getAccessibleFileSystemEntries(path: string): ts.FileSystemEntries {

src/harness/virtualFileSystemWithWatch.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ interface Array<T> { length: number; [n: number]: T; }`
922922
});
923923
}
924924
return { directories, files };
925-
}, path => this.realpath(path), path => this.directoryExists(path));
925+
}, path => this.realpath(path));
926926
}
927927

928928
createHash(s: string): string {

0 commit comments

Comments
 (0)