Skip to content

watch: NODE_OPTIONS=--watch causes infinite loop #61740

Description

@ericnorris

Version

v25.6.0

Platform

Darwin <redacted> 24.6.0 Darwin Kernel Version 24.6.0: Wed Nov  5 21:33:58 PST 2025; root:xnu-11417.140.69.705.2~1/RELEASE_ARM64_T6000 arm64 arm Darwin

Subsystem

No response

What steps will reproduce the bug?

  1. Write the following to test.js and make it executable:
    #!/usr/bin/env node
    console.log('hello');
  2. NODE_OPTIONS="--watch" ./test.js

How 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 hello in stdout and then exiting.

What do you see instead?

There is no output. I can see in my process list that there are hundreds of node processes spawning.

Additional information

This seems to be the same issue as #51159. For additional context, my intent was to reuse a bin entrypoint in package.json but with --watch mode, so under the scripts field it looked roughly like:

"scripts": {
    "dev": "NODE_OPTIONS='--watch' app",
}

...where app is in node_modules/.bin/.

Activity

  1. Renegade334 commented on Feb 8, 2026

    @Renegade334
    Member

    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
  2. kennedybilly2 commented on Feb 8, 2026

    @kennedybilly2
  3. marco-ippolito commented on Feb 11, 2026

    @marco-ippolito
    Member

    I'll take a look

  4. Renegade334 commented on Feb 11, 2026

    @Renegade334
    Member

    FYI node --watch with no arguments is considered valid since that change, which seems a little counter-intuitive

    renegade@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:~$
  5. Renegade334 commented on Feb 14, 2026

    @Renegade334
    Member

    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=--watch without 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
  6. vassudanagunta commented on Jun 25, 2026

    @vassudanagunta
    Contributor

    FYI node --watch with no arguments is considered valid since that change, which seems a little counter-intuitive

    Opened issue #64135

  7. vikram0x00 commented on Aug 21, 2026

    @vikram0x00

    Using node --watch index.js caused a similar behavior in my Express Application, which restarted on every incoming request from the client.
    Also using that command causes a change event on the index.js file.

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

    confirmed-bugIssues and PRs for confirmed bugs.watch-modeIssues and PRs related to watch mode.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions