Repository navigation
watch: NODE_OPTIONS=--watch causes infinite loop #61740
Description
Activity
Appears in v25.1.0, most likely relating to #60178 (cc @marco-ippolito)
renegade@venus:~$ echo 'console.log("Hello, world!")' > test.cjs && NODE_OPTIONS=--watch node test.cjs & [1] 84511 renegade@venus:~$ pidof node 84729 84723 84717 84711 84705 84699 84693 84687 84679 84673 84667 84661 84653 84647 84641 84635 84629 84623 84617 84611 84604 84597 84591 84585 84579 84573 84567 84561 84555 84549 84543 84537 84531 84525 84511 renegade@venus:~$ pidof node 84817 84811 84805 84799 84793 84787 84781 84775 84769 84763 84755 84749 84739 84729 84723 84717 84711 84705 84699 84693 84687 84679 84673 84667 84661 84653 84647 84641 84635 84629 84623 84617 84611 84604 84597 84591 84585 84579 84573 84567 84561 84555 84549 84543 84537 84531 84525 84511 renegade@venus:~$ pidof node 84875 84867 84861 84855 84849 84843 84837 84831 84817 84811 84805 84799 84793 84787 84781 84775 84769 84763 84755 84749 84739 84729 84723 84717 84711 84705 84699 84693 84687 84679 84673 84667 84661 84653 84647 84641 84635 84629 84623 84617 84611 84604 84597 84591 84585 84579 84573 84567 84561 84555 84549 84543 84537 84531 84525 84511 renegade@venus:~$ pidof node 84919 84913 84907 84901 84895 84889 84875 84867 84861 84855 84849 84843 84837 84831 84817 84811 84805 84799 84793 84787 84781 84775 84769 84763 84755 84749 84739 84729 84723 84717 84711 84705 84699 84693 84687 84679 84673 84667 84661 84653 84647 84641 84635 84629 84623 84617 84611 84604 84597 84591 84585 84579 84573 84567 84561 84555 84549 84543 84537 84531 84525 84511 renegade@venus:~$ pidof node 84972 84966 84960 84952 84946 84940 84931 84919 84913 84907 84901 84895 84889 84875 84867 84861 84855 84849 84843 84837 84831 84817 84811 84805 84799 84793 84787 84781 84775 84769 84763 84755 84749 84739 84729 84723 84717 84711 84705 84699 84693 84687 84679 84673 84667 84661 84653 84647 84641 84635 84629 84623 84617 84611 84604 84597 84591 84585 84579 84573 84567 84561 84555 84549 84543 84537 84531 84525 84511 renegade@venus:~$ pidof node 85022 85016 85010 85004 84998 84992 84986 84972 84966 84960 84952 84946 84940 84931 84919 84913 84907 84901 84895 84889 84875 84867 84861 84855 84849 84843 84837 84831 84817 84811 84805 84799 84793 84787 84781 84775 84769 84763 84755 84749 84739 84729 84723 84717 84711 84705 84699 84693 84687 84679 84673 84667 84661 84653 84647 84641 84635 84629 84623 84617 84611 84604 84597 84591 84585 84579 84573 84567 84561 84555 84549 84543 84537 84531 84525 84511
- addedconfirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.watch-modeIssues and PRs related to watch mode.Issues and PRs related to watch mode.
on Feb 8, 2026 I'll take a look
FYI
node --watchwith no arguments is considered valid since that change, which seems a little counter-intuitiverenegade@venus:~$ node --watch Welcome to Node.js v24.13.1. Type ".help" for more information. > .exit Completed running ''. Waiting for file changes before restarting... renegade@venus:~$
Appears in v25.1.0, most likely relating to #61626
So, it looks like this bug actually existed before that PR. The only difference is that
NODE_OPTIONS=--watchwithout a filename parameter used to be rejected prior to that change; the bug still existed, but it was just slightly unnatural to trigger:renegade@mercury:~$ node -v v22.21.0 renegade@mercury:~$ NODE_OPTIONS='--watch' node test.cjs node: --watch requires specifying a file renegade@mercury:~$ NODE_OPTIONS='--watch dummy-parameter' node test.cjs & [1] 518467 renegade@mercury:~$ pidof node 518812 518805 518799 518793 518787 518781 518775 518769 518763 518757 518751 518745 518739 518733 518727 518721 518715 518709 518703 518697 518691 518685 518679 518673 518667 518661 518655 518649 518643 518637 518631 518625 518619 518613 518607 518601 518595 518589 518583 518577 518570 518563 518557 518551 518545 518539 518533 518527 518521 518515 518509 518503 518497 518491 518485 518479 518467
FYI
node --watchwith no arguments is considered valid since that change, which seems a little counter-intuitiveOpened issue #64135
Using
node --watch index.jscaused a similar behavior in my Express Application, which restarted on every incoming request from the client.
Also using that command causes achangeevent on theindex.jsfile.- added a commit that references this issue
on Sep 22, 2026 - added a commit that references this issue
on Sep 27, 2026
Version
v25.6.0
Platform
Subsystem
No response
What steps will reproduce the bug?
test.jsand make it executable:NODE_OPTIONS="--watch" ./test.jsHow often does it reproduce? Is there a required condition?
This is always reproducible.
What is the expected behavior? Why is that the expected behavior?
I would expect it to run normally, producing
helloinstdoutand then exiting.What do you see instead?
There is no output. I can see in my process list that there are hundreds of
nodeprocesses spawning.Additional information
This seems to be the same issue as #51159. For additional context, my intent was to reuse a
binentrypoint inpackage.jsonbut with--watchmode, so under thescriptsfield it looked roughly like:...where
appis innode_modules/.bin/.