Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

fs.watchFile does not detect deletion of unmodified files under certain conditions. #4027

@dominictarr

Description

@dominictarr

If you fs.watchFile(file,...) a newly created flie in the listener of a fs.watchFile on it's parent directory,
then delete that file without otherwise modifying it, then that delete will never be noticed.

Here is a script to reproduce:
https://gist.github.com/50ac9170e4615df2b644

first discovered this here
mikeal/watch#36

This bug only strikes when you start watching a new file in response to it's creation (which you detected by watching it's directory). If the file already exists when you start node, (and you start watching it after traversing that directory) then it will be detected correctly.

the deletion can be detected by doing an fs.readdir,
and then comparing that list to what you though you had.
but there is probably a much better way to fix this bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions