-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Closed
Labels
watch-modeIssues and PRs related to watch modeIssues and PRs related to watch mode
Description
Version
v22.0.0
Platform
Darwin MacBook-Pro-de-Matthieu.local 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:25 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6030 arm64
Subsystem
watch
What steps will reproduce the bug?
- from a project that uses a lot of files (see snippet bellow)
- start the project with
node --watch
- From another terminal
touch
multiple dependencies with a small sleep in between (for f in files/*; do touch $f; sleep 0.1; done
) - notice that Node restarts the program without applying debounce
Here is a script to set this up
// gen.mjs
import { writeFileSync, mkdirSync }from 'node:fs'
mkdirSync('./files', { recursive: true })
writeFileSync(`./files/0.mjs`, `export const log = (message) => console.log(message)`)
for (let i = 1; i < 100; i++) {
writeFileSync(`./files/${i}.mjs`, `export { log } from './${i - 1}.mjs'`)
}
How often does it reproduce? Is there a required condition?
When using node --watch
on a project that has live build (eg. tsc --watch
), it happens very often as the typescript compiler seems to generate/update/touch lots of files, even when only one source file is updated.
What is the expected behavior? Why is that the expected behavior?
There is currently a debounce that prevent node from restarting the program when a single file file is updated in a short delay. This debounce should also happen when other files are updated within the same delay.
What do you see instead?
The debouncing behavior of watch does not apply when multiple files are updated
Additional information

tonivj5
Metadata
Metadata
Assignees
Labels
watch-modeIssues and PRs related to watch modeIssues and PRs related to watch mode