nodejs / nodejs/node

--watch restarts only once

Open
#54,774 17 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

libuv stale watch-mode
Dominant language
JavaScript
Stars
122k
Forks
37.3k
Avg merge
4d 2h
Merged PRs (30d)
283

Description

Version

v20.15.1

Platform
Linux derby 6.6.46-0-lts #1-Alpine SMP PREEMPT_DYNAMIC 2024-08-16 08:05:54 x86_64 Linux
Subsystem

No response

What steps will reproduce the bug?

f.js contains only console.log('hello')

node --watch f.js
hello
Completed running 'f.js'

Change f.js to console.log('hello world')

Restarting 'f.js'
hello world
Completed running 'f.js'

Change f.js again, e.g. console.log('this change will not restart watcher')
No change in the watch output.

(I'm changing the file outside of the debounce/throttle period)

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

It happens every time.

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

I would expect that --watch would restart after every write to f.js, not just after the first change made to the file.

What do you see instead?

--watch only seems to restart after making the first change to the file.

Additional information

Also seeing this problem on Termux for Android node v22.5.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with node --watch f.js, changing the file more than once outside the debounce/throttle period. Trace the --watch entry point and its restart handling; done means every subsequent write to f.js restarts the process and the behavior is verified on the reported environment.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.