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

FileSystemWatcher may miss event when many changes are happening in a short order #220039

Closed
cdietrich opened this issue Jul 5, 2024 · 11 comments
Assignees
Labels
file-watcher File watcher info-needed Issue requires more information from poster upstream Issue identified as 'upstream' component related (exists outside of VS Code)

Comments

@cdietrich
Copy link

cdietrich commented Jul 5, 2024

  • VS Code Version: 1.91.0
  • OS Version: MacOS Sonoma 14.5

Register a file System watcher

const w = vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(vscode.workspace.workspaceFolders![0],"*.txt"));
w.onDidDelete((e) => {
	console.log(e);
	counter++;
});

do a deletion of a huge number of files (would also happen on creation)
then the watch may omit some changes

(when used together with a language server/vscode-language-client this will be bad a the state in the server might become out of sync)

here is an attempt to write a reproducing test

https://github.com/cdietrich/fs-watcher-bug/blob/main/src/test/extension.test.ts

originally reported as microsoft/vscode-languageserver-node#1503

cc @dbaeumer

@ocallesp
Copy link
Member

ocallesp commented Jul 25, 2024

This bug is also affecting the Test Explorer in C# DevKit (microsoft/vscode-dotnettools#996), causing it to miss some test methods. This issue is disrupting the user experience significantly on our end.

I have a repro case in VS Code v1.92.0-insider (Universal) where after opening a solution with 10 projects and performing a build, the Test Explorer shows incomplete test projects.

@bpasero is there any milestone set for resolving this bug ?

@bpasero
Copy link
Member

bpasero commented Aug 5, 2024

Would be great to distill a reproducible case using https://github.com/parcel-bundler/watcher, which is the file watcher we leverage so that it can be reported upstream, if it turns out to be.

@cdietrich
Copy link
Author

cdietrich commented Aug 8, 2024

@bpasero maybe https://github.com/cdietrich/parcel-watcher-bug helps
funny thing. when installing and using watchman as backend (under mac) the results are ok
so there seems to be a diff in parcel-watcher and watchmans usage of apples api

as we seem to have problems also on linux (but i dont see it with the test above - ok sometimes it gets 0 changes). i also need to further investigate. does vscode use a specific backend for linux?

@bpasero
Copy link
Member

bpasero commented Aug 9, 2024

@cdietrich here is my output on macOS:

~/Desktop/parcel-watcher-bug> node index.js
1001
counter 1000
1
~/Desktop/parcel-watcher-bug> 

What do you get?

We use the standard backend for parcel watcher, so it would be inotify on Linux.

@cdietrich
Copy link
Author

cdietrich commented Aug 9, 2024

if i run multiple times it will say

counter 567
or counter 998
or counter 867

on linux its much much more seldom

@cdietrich
Copy link
Author

from my m2 pro

while ./node_modules/.bin/ts-node index.ts; do :; done
1001
counter 1000
1
1001
counter 1000
1
1001
counter 1000
1
1001
counter 1000
1
1001
counter 1000
1
1001
counter 1000
1
1001
counter 1000
1
1001
counter 1000
1
1001
counter 1000
1
1001
counter 1000
1
1001
counter 1000
1
1001
counter 1000
1
1001
counter 1000
1
1001
counter 1000
1
1001
counter 779
1
1001
counter 1000
1
1001
counter 1000
1
1001
counter 1000
1
1001
counter 1000
1
1001
counter 1000
1
1001
counter 1000
1
1001
counter 1000
1
1001
counter 1000
1
1001
counter 1000
1
1001
counter 1000
1
1001
counter 593
1
1001
counter 1000
1
1001

on my private m1 air much more often.

@bpasero
Copy link
Member

bpasero commented Aug 9, 2024

@cdietrich got it, I would think you can report this with your repro at https://github.com/parcel-bundler/watcher

@cdietrich
Copy link
Author

done parcel-bundler/watcher#183

@bpasero
Copy link
Member

bpasero commented Aug 9, 2024

Thanks a ton for the issue and repro, thats helpful, I am going ahead and close this as upstream. I am monitoring the parcel repository for fixes.

@bpasero bpasero closed this as completed Aug 9, 2024
@bpasero bpasero added the upstream Issue identified as 'upstream' component related (exists outside of VS Code) label Aug 9, 2024
@bpasero bpasero reopened this Aug 12, 2024
@bpasero
Copy link
Member

bpasero commented Aug 12, 2024

Re-opening to keep understanding the issue microsoft/vscode-dotnettools#996 and whether that is the same underlying problem.

@ocallesp curious if you can be certain that this issue is really the same issue?

@bpasero bpasero added the info-needed Issue requires more information from poster label Aug 12, 2024
Copy link

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

@vs-code-engineering vs-code-engineering bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 20, 2024
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Oct 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
file-watcher File watcher info-needed Issue requires more information from poster upstream Issue identified as 'upstream' component related (exists outside of VS Code)
Projects
None yet
Development

No branches or pull requests

4 participants