Skip to content

node --watch-path: Does not restart when re-creating subdir on Linux #67592

Open

Description

@lydell

Version

v26.13.1

Platform

Linux ubuntu 7.2.12-orbstack-00394-gbecdd6130068 #1 SMP PREEMPT Thu Oct 22 22:17:17 UTC 2026 aarch64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

index.js (a stupid long-running program that can be restarted with --watch):

console.log(new Date);
process.stdin.resume();

generate.js (some kind of code generation script):

import fs from "fs";

// Clear generated folder:
fs.rmSync("assets/generated", { recursive: true, force: true });
fs.mkdirSync("assets/generated", { recursive: true });

// Generate files:
fs.writeFileSync("assets/generated/a.txt", `${Date.now()}`);

Run in one terminal: node --watch-path assets --watch-preserve-output index.js

Run in another terminal: node generate.js (multiple times)

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

Always.

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

Output on macOS:

❯ node --watch-path assets --watch-preserve-output index.js
2026-11-18T19:13:55.414Z
Change detected in '/Users/me/stuff/node-watch-bug-linux/assets/generated/a.txt'
Restarting 'index.js'
2026-11-18T19:13:59.098Z
Change detected in '/Users/me/stuff/node-watch-bug-linux/assets/generated/a.txt'
Restarting 'index.js'
2026-11-18T19:14:00.181Z
Change detected in '/Users/me/stuff/node-watch-bug-linux/assets/generated/a.txt'
Restarting 'index.js'
2026-11-18T19:14:01.155Z

I ran generate.js three times, and it restarted three times as expected.

What do you see instead?

Output on Linux:

$ node --watch-path assets --watch-preserve-output index.js
2026-11-18T19:12:31.961Z
Change detected in '/mnt/e/node-watch-bug-linux/assets/generated/a.txt'
Restarting 'index.js'
2026-11-18T19:12:39.721Z

There is just one restart, even though I ran generate.js three times. I expected three restarts.

Additional information

I think it’s common to nuke a folder and recreate it before generating things.

I reproduced this in a Linux Virtual Machine (via OrbStack on macOS) with ext4 file system (no mounting into the macOS file system), but I’m pretty sure the same thing happens on a real Linux machine as well.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions