Skip to content

Swallow the directory watcher exceptions and ignore them#19058

Merged
sheetalkamat merged 4 commits into
masterfrom
whenWatchesFail
Oct 11, 2017
Merged

Swallow the directory watcher exceptions and ignore them#19058
sheetalkamat merged 4 commits into
masterfrom
whenWatchesFail

Conversation

@sheetalkamat
Copy link
Copy Markdown
Member

  • Always use parent most node_modules directory to watch, that should reduce the directory watchers
  • Swallow directory watcher exceptions - the better approach is to either do polling directory watch or some sort of host handled directory watches, but this should fix the experience for now
    Fixes ENOSPC results in "Error: No Project" #18996

@sheetalkamat
Copy link
Copy Markdown
Member Author

@mhegazy or @Andy-MS can you please take a look

Comment thread src/compiler/resolutionCache.ts Outdated
let dirPath = getDirectoryPath(failedLookupLocationPath);

// If directory path contains node module, get the most parent node_modules directory for watching
while (dirPath.indexOf("/node_modules/") !== -1) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use a stringContains helper function.

Comment thread src/server/server.ts Outdated
const sys = <ServerHost>ts.sys;
// use watchGuard process on Windows when node version is 4 or later
const useWatchGuard = process.platform === "win32" && getNodeMajorVersion() >= 4;
const originalWatchDirectory = sys.watchDirectory;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For type safety, consider const originalWatchDirectory: ServerHost["watchDirectory"] = sys.watchDirectory.bind(sys); and call it like a normal function.
But what if sys.watchDirectory is absent -- apparently this is optional?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for @Andy-MS's suggession.

Also consider adding a comment why we swallow these exceptions e.g. in the Linux case

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is optional but tsserver had it like that all the time.

@sheetalkamat sheetalkamat merged commit a7fa187 into master Oct 11, 2017
@sheetalkamat sheetalkamat deleted the whenWatchesFail branch October 11, 2017 01:32
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ENOSPC results in "Error: No Project"

2 participants