Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watch does not debounce restart when different files are updated within the debounce period #52721

Closed
matthieusieben opened this issue Apr 27, 2024 · 0 comments · Fixed by #52722
Labels
watch-mode Issues and PRs related to watch mode

Comments

@matthieusieben
Copy link
Contributor

matthieusieben commented Apr 27, 2024

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?

  1. from a project that uses a lot of files (see snippet bellow)
  2. start the project with node --watch
  3. From another terminal touch multiple dependencies with a small sleep in between (for f in files/*; do touch $f; sleep 0.1; done)
  4. 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

Capture d’écran 2024-04-27 à 14 20 53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
watch-mode Issues and PRs related to watch mode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants