Skip to content

Events are dropped when watching multiple files from one FSWatcher #1437

@johnjohntheleprechaun

Description

@johnjohntheleprechaun

Description

When watching more than one file (non-polling), atomic writes on any files other than the first one that's changed are emitted as an unlink event, and then no more events are emitted for that file. The file that was written first continues to properly emit all events.

Versions:

  • Chokidar: 4.0.3
  • Node: v22.14.0
  • OS: NixOS 25.05.802491.7c43f080a7f2 (Warbler)

Reproducing

import { watch } from "chokidar";

watch(["a", "b", "c"], {
    persistent: true,
    atomic: 500, // delay doesn't seem to affect bug behavior
}).on("all", (...a) => console.log(a));

It's assumed that all three files (a, b, and c) already exist

  • Update file a with an atomic write (I use neovim). This will emit a change event.
  • Update files b and c. Both of these will emit an unlink event after 500ms (or whatever delay was set)

Expected Behavior

All file updates should emit a change event

Context and Thoughts

I've reproduced this issue on NixOS and Ubuntu on WSL, so I don't think it's system specific. Also, watching each file with a completely separate FSWatcher works just fine, but that's effectively what the single watcher should be doing under the hood anyway so I can't imagine why. I imagine the problem is just a minor logic bug, so I'll look at the source myself to see if I can figure it out. Can't be much harder than building a workaround.... right?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions