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

too many duplicate events #121

Open
gpetrov opened this issue Oct 6, 2020 · 5 comments
Open

too many duplicate events #121

gpetrov opened this issue Oct 6, 2020 · 5 comments

Comments

@gpetrov
Copy link

gpetrov commented Oct 6, 2020

When doing a multiple file copy of a watched folder, many duplicate events are being generated.

{action: 0, directory: "watched_directory\dir1", file: "file1.ext"}
{action: 2, directory: "watched_directory\dir1", file: "file1.ext"}
{action: 2, directory: "watched_directory\dir1", file: "file1.ext"}
{action: 2, directory: "watched_directory", file: "dir1"}
{action: 0, directory: "watched_directory\dir1", file: "file2.ext"}
{action: 2, directory: "watched_directory\dir1", file: "file2.ext"}
{action: 2, directory: "watched_directory\dir1", file: "file2.ext"}
{action: 2, directory: "watched_directory", file: "dir1"}
{action: 0, directory: "watched_directory\dir1", file: "file3.ext"}
{action: 2, directory: "watched_directory\dir1", file: "file3.ext"}
{action: 2, directory: "watched_directory\dir1", file: "file3.ext"}
{action: 2, directory: "watched_directory", file: "dir1"}
{action: 0, directory: "watched_directory\dir1", file: "file4.ext"}
{action: 2, directory: "watched_directory\dir1", file: "file4.ext"}
{action: 2, directory: "watched_directory\dir1", file: "file4.ext"}
{action: 2, directory: "watched_directory", file: "dir1"}

Would it be much wiser if before adding a change event to the queue first a check is done if it is already in it @implausible ?

So that we don't have to dedupe all the events first before processing?

@gpetrov
Copy link
Author

gpetrov commented Oct 9, 2020

After further investigation, it seems the route cause on Windows seems to be FILE_NOTIFY_CHANGE_LAST_ACCESS flag.

This causes a change event on each file read ... is this really desired? As there is really nothing changed - file is just "accessed"

Maybe we should just remove this flag @implausible or an an option for it?

Is this also Windows only? Seems that on MacOS at least no change events are triggered when file is just accessed.

A as similar issue with the node watch code: nodejs/node#21643 (comment)

@implausible
Copy link
Contributor

Awesome sleuthing. Let's go ahead and remove that flag. I agree, that is not something that we need to track. If we see push back we can course correct with an option.

@bpasero
Copy link

bpasero commented Sep 24, 2021

It is maybe worth mentioning that the default C# file system watcher uses these flags:

https://github.com/dotnet/runtime/blob/6b11f64ec09983013862c2fd85ba29c940c44eea/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.cs#L29

NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName

We have been using these flags for a long time on Windows in VSCode without issues. In our (new) fork of nsfw, we pushed this commit:

https://github.com/microsoft/vscode-nsfw/commit/97c11885bd03d36f5c6286b8bdbfbc1ec649f295

@bpasero
Copy link

bpasero commented Sep 25, 2021

PR: #147

@leopucci
Copy link

This seems to be happening still.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants