Skip to content

fs.watchFile inconsistent stat return #15364

@dragosnicolae

Description

@dragosnicolae
  • Version: tested on v8.4.0 and v6.11.2
  • Platform: GNU/Linux (Centos 7)

Hi!

I encountered the following problem when using fs.watchFile. I start watching a file, let's say file1, the file is renamed into file2 and then back into file1.

On the first rename, my listener is called with currentStat filled with 0s (correct, as the file does not exist) and some values for the previousStat.

On the second rename, when the file gets the name it had initially, the previousStat is the same one as the previousStat of the first rename (I think it should be the one filled with 0s, as the file did not exist previously) and has the same modified time as the currentStat. This way, I cannot determine that the file has reappeared.

I am comparing that the modified time has changed in order to avoid false alarms triggered by file access as specified in the Node.js documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to the documentations.fsIssues and PRs related to the fs subsystem / file system.good first issueIssues that are suitable for first-time contributors.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions