Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Watcher race on Windows with new directory and file modification #2234

@davidmorgan

Description

@davidmorgan

If you create a new directory, create a new file in it, then modify the file ... the new directory gets listed, there is a race, the list might already see the new file. That races with the new file event and modify event. New file event and modify event arriving together get combined into just "new file". "New file" is then discarded because the file has already been seen in the list and reported as a new file. The modify event that was combined with the new file event is just dropped, so the last modification is never notified, and the state seen is from before the modification.

So the fix should be something like: discard "add" events for already-notified files before merging "modify" events into "add" events.

The bizarre "time travel" effect was because an earlier notification from the list was replacing a later one from the modification, so the user of package:watcher does actually get notified earlier and see an earlier state.

Discovered while adding an e2e test.

There is currently a 100ms delay baked into the Windows directory watcher, I suspect it relates to this race and can be reduced/removed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions