Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use vscode watches for tsserver #193848

Merged
merged 28 commits into from
Apr 9, 2024
Merged

Conversation

sheetalkamat
Copy link
Member

@bpasero
Copy link
Member

bpasero commented Sep 23, 2023

🆒 , is this the change that would enable file watching in all of TS extension with the VS Code file watcher or is there more needed?

@sheetalkamat
Copy link
Member Author

is this the change that would enable file watching in all of TS extension with the VS Code file watcher or is there more needed?

Yes microsoft/TypeScript#54662 should redirect all the watch calls by tsserver into vscode if invoked with --canUseWatchEvents

@mjbvz mjbvz added this to the October 2023 milestone Sep 26, 2023
@bpasero
Copy link
Member

bpasero commented Oct 10, 2023

Fyi #194776 landed which enables extensions to do full recursive file watching anywhere even within the workspace with custom exclude rules. It is behind proposed API (createFileSystemWatcher).

@mjbvz
Copy link
Collaborator

mjbvz commented Oct 18, 2023

@sheetalkamat I pushed a change that gates this feature behind a setting and also tries to clean up file watchers when the server restarts

In my testing, I see errors such as this in the developer tools:

 MainThreadFileSystemEventService#$watch(): failed to stat a resource for file watching (extension: vscode.typescript-language-features, path: file:///Users/matb/projects/node_modules, recursive: true, session: 0.16141590890668556): EntryNotFound (FileSystemError): Error: ENOENT: no such file or directory, stat '/Users/matb/projects/node_modules'

Will this cause any issues for TypeScript? It seems like we may be trying to watch the contents of a directory that does not exist. Will we still pick up if the directory is created later?

@sheetalkamat
Copy link
Member Author

Will this cause any issues for TypeScript? It seems like we may be trying to watch the contents of a directory that does not exist. Will we still pick up if the directory is created later?

We do need to watch even if directory does not exist and get events when it gets created. (Without this we wouldnt be picking up changes to project resolutions because of npm install)
@bpasero is this supported. Are the errors because i am yet to add exclude pattern.

@bpasero
Copy link
Member

bpasero commented Oct 18, 2023

@sheetalkamat no, that is not supported. you have to watch a parent folder that exists. Maybe then you will have to watch the workspace folder(s) and do a negated exclude pattern such as !**/node_modules/** to recursively watch any node module folder that is either there already or gets created.

@mjbvz mjbvz modified the milestones: March 2024, April 2024 Mar 26, 2024
@kieferrm kieferrm mentioned this pull request Apr 7, 2024
53 tasks
bpasero
bpasero previously approved these changes Apr 9, 2024
@bpasero bpasero enabled auto-merge (squash) April 9, 2024 11:08
@bpasero bpasero merged commit b2c4302 into microsoft:main Apr 9, 2024
6 checks passed
@sheetalkamat sheetalkamat deleted the canUseWatchEvents branch April 9, 2024 17:06
@microsoft microsoft locked and limited conversation to collaborators Jun 11, 2024
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.

4 participants