Skip to content

fs.watch recursive on Linux emits spurious rename events for sibling files/directories prefixed by related paths on deletion #58868

Open
@Sodium-Aluminate

Description

@Sodium-Aluminate

Version

v24.2.0 (from archlinux) and v24.1.0 (from nwjs)

Platform

Linux ****** 6.15.2-arch1-1 #1 SMP PREEMPT_DYNAMIC Tue, 10 Jun 2025 21:32:33 +0000 x86_64 GNU/Linux

Subsystem

fs

What steps will reproduce the bug?

  1. open 2 window, prepare test files in the first window:
mkdir -p foo_bar/somedir
touch foo_bar/file.txt
mkdir foo
touch foo_
  1. open a node repl in the second window:
fs.watch(".", { recursive: true }, console.log);
  1. keep the node running, back to the first window:
rmdir foo

Observed output in the second window:

rename foo
rename foo_
rename foo_bar
rename foo_bar/file.txt
rename foo_bar/somedir

and then:

rm foo_

Observed output in the second window:

rename foo_
rename foo_bar
rename foo_bar/file.txt
rename foo_bar/somedir

How often does it reproduce? Is there a required condition?

N/A

What is the expected behavior? Why is that the expected behavior?

expected not send the unrelated event(in test case, foo_bar is unchanged, but we got a fake event)

What do you see instead?

(already attached output in reproduce steps)

Image

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to the fs subsystem / file system.linuxIssues and PRs related to the Linux platform.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions