GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — watch: strip watch flags from NODE_OPTIONS in child process by marcopiraccini · Pull Request #62143 · nodejs/node

Conversation

@marcopiraccini

@marcopiraccini marcopiraccini commented Mar 7, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

When NODE_OPTIONS contains --watch, the watch mode parent process spawns a child that inherits the same NODE_OPTIONS, causing the child to also enter watch mode and spawn another child, creating an infinite loop of process spawning.

This PR strips watch-related flags (--watch, --watch-path,--watch-preserve-output, --watch-kill-signal) from NODE_OPTIONS before passing the environment to the child process. This mirrors the existing logic that already strips these flags from process.execArgv.

Non-watch flags in NODE_OPTIONS (e.g., --max-old-space-size) are preserved.

To properly handle quoted strings and backslash escapes in NODE_OPTIONS values (e.g., --require "./path with --watch in name/f.js"), the C++ ParseNodeOptionsEnvVar tokenizer is exposed to JavaScript via a new internalBinding('options') method. This reuses the exact same parser that Node.js uses at startup, ensuring consistent behavior.

Fixes: #61740

This is actually similar to #61838 but more "surgical", it just avoid propagating watch flags.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Mar 7, 2026
@marcopiraccini
marcopiraccini marked this pull request as ready for review March 7, 2026 05:56
@codecov

codecov Bot commented Mar 7, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.47619% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.34%. Comparing base (e2ad744) to head (9def55c).
⚠️ Report is 1650 commits behind head on main.

Files with missing lines Patch % Lines
src/node_options.cc 89.47% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #62143      +/-   ##
==========================================
+ Coverage   90.31%   90.34%   +0.02%     
==========================================
  Files         730      730              
  Lines      234463   234484      +21     
  Branches    43908    43918      +10     
==========================================
+ Hits       211763   211835      +72     
+ Misses      14419    14368      -51     
  Partials     8281     8281              
Files with missing lines Coverage Δ
lib/internal/options.js 37.28% <100.00%> (+1.43%) ⬆️
src/node_options.cc 77.30% <89.47%> (+0.62%) ⬆️

... and 33 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Renegade334
Renegade334 reviewed Mar 8, 2026
View reviewed changes
Comment thread lib/internal/main/watch_mode.js Outdated
let cleanNodeOptions = kNodeOptions;
if (kNodeOptions != null) {
const nodeOptionsArgs = [];
const parts = RegExpPrototypeSymbolSplit(/\s+/, kNodeOptions);

@Renegade334 Renegade334 Mar 8, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ultimately, this sort of approach isn't robust enough.

$ mkdir 'test for --watch parsing'
$ echo 'console.log("hi!")' > 'test for --watch parsing/test.cjs'
$ NODE_OPTIONS='--require "./test for --watch parsing/test.cjs"' node -p 'process.env.NODE_OPTIONS.split(" ")'
hi!
[ '--require', '"./test', 'for', '--watch', 'parsing/test.cjs"' ]
                                  ^^^^^^^

I suspect this is going to need to interact with the options parser in some way.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@marcopiraccini marcopiraccini Mar 8, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.
Thinking about it, maybe adding a C++ binding that exposes ParseNodeOptionsEnvVar to JS would be more robust (being the same parser to interpret NODE_OPTIONS, in my undersanding) and then finltering out watch flags. Will amend this PR.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@marcopiraccini marcopiraccini Mar 8, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Renegade334 PTAL

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Renegade334 Renegade334 added the watch-mode Issues and PRs related to watch mode. label Mar 8, 2026
@Pjrich1313 Pjrich1313 mentioned this pull request Mar 8, 2026
Create new issue in Nodejs/node api reference doc #62155
Closed
MoLow
MoLow approved these changes Mar 25, 2026
View reviewed changes
Renegade334
Renegade334 reviewed Apr 7, 2026
View reviewed changes
Comment thread src/node_options.cc Resolved

Uh oh!

There was an error while loading. Please reload this page.

ShogunPanda
ShogunPanda approved these changes May 5, 2026
View reviewed changes
Renegade334
Renegade334 approved these changes May 5, 2026
View reviewed changes
@Renegade334

Renegade334 commented May 5, 2026

Copy link
Copy Markdown
Member

Oh, there's a test failing on macOS.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@marcopiraccini

marcopiraccini commented May 6, 2026

Copy link
Copy Markdown
Contributor Author

Oh, there's a test failing on macOS.

Because of --without-node-options for darwin. see:

node/.github/workflows/test-shared.yml

Line 167 in d179c7e

${{ endsWith(matrix.system, '-darwin') && '--arg withAmaro false --arg withLief false --arg withSQLite false --arg withFFI false --arg extraConfigFlags ''["--without-inspector" "--without-node-options"]'' \' || '\' }}

PTAL

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@marcopiraccini
marcopiraccini force-pushed the fix/watch-node-options-infinite-loop branch from 4cbc589 to ae30387 Compare May 24, 2026 06:57
@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label May 24, 2026
mcollina
mcollina approved these changes May 24, 2026
View reviewed changes

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label May 24, 2026
@nodejs-github-bot

nodejs-github-bot commented May 24, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/73677/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

marcopiraccini added 6 commits May 26, 2026 05:10
@marcopiraccini
watch: strip watch flags from NODE_OPTIONS in child process
82f7946
Signed-off-by: marcopiraccini <[email protected]>
@marcopiraccini
watch: strip watch flags from NODE_OPTIONS in child process
cb08852
Signed-off-by: marcopiraccini <[email protected]>
@marcopiraccini
fixup
d53aea2
Signed-off-by: marcopiraccini <[email protected]>
@marcopiraccini
fixup
e78ac78
Signed-off-by: marcopiraccini <[email protected]>
@marcopiraccini
fixup after review
7727a39
Signed-off-by: marcopiraccini <[email protected]>
@marcopiraccini
test: skip --watch NODE_OPTIONS test without NODE_OPTIONS support
9def55c
Signed-off-by: marcopiraccini <[email protected]>
@marcopiraccini
marcopiraccini force-pushed the fix/watch-node-options-infinite-loop branch from ae30387 to 9def55c Compare May 26, 2026 03:10
@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

This pull request has been marked as stale due to 90 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Issues and PRs marked stale due to inactivity and scheduled for automatic closure. label Aug 25, 2026
trivikr
trivikr approved these changes Sep 7, 2026
View reviewed changes
@trivikr trivikr added request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. and removed stale Issues and PRs marked stale due to inactivity and scheduled for automatic closure. labels Sep 7, 2026
@nodejs-github-bot

nodejs-github-bot commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/77734/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@trivikr trivikr added commit-queue-squash PRs the Commit Queue should land as one squashed commit. commit-queue PRs queued for automated landing through the Commit Queue. labels Sep 22, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 1eacebb into nodejs:main Sep 22, 2026
78 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

Landed in 1eacebb

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Sep 22, 2026
aduh95 pushed a commit that referenced this pull request Sep 27, 2026
@marcopiraccini @aduh95
watch: strip watch flags from NODE_OPTIONS in child process
be7f637
Signed-off-by: marcopiraccini <[email protected]>
PR-URL: #62143
Fixes: #61740
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Paolo Insogna <[email protected]>
Reviewed-By: René <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
@github-actions github-actions Bot mentioned this pull request Oct 5, 2026
2026-10-07, Version 26.11.0 (Current) #66546
Merged
aduh95 pushed a commit that referenced this pull request Oct 23, 2026
@marcopiraccini @aduh95
watch: strip watch flags from NODE_OPTIONS in child process
ed8e4f4
Signed-off-by: marcopiraccini <[email protected]>
PR-URL: #62143
Fixes: #61740
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Paolo Insogna <[email protected]>
Reviewed-By: René <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
aduh95 pushed a commit that referenced this pull request Oct 28, 2026
@marcopiraccini @aduh95
watch: strip watch flags from NODE_OPTIONS in child process
abaaa6a
Signed-off-by: marcopiraccini <[email protected]>
PR-URL: #62143
Fixes: #61740
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Paolo Insogna <[email protected]>
Reviewed-By: René <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
@leapmux-renovate leapmux-renovate Bot mentioned this pull request Nov 1, 2026
chore(deps): Update Node.js to v26 leapmux/leapmux#578
Merged
@colinhacks colinhacks mentioned this pull request Nov 5, 2026
node: keep watch mode out of its children under every spelling and channel nubjs/nub#1086
Merged
aduh95 pushed a commit that referenced this pull request Nov 11, 2026
@marcopiraccini @aduh95
watch: strip watch flags from NODE_OPTIONS in child process
56471e4
Signed-off-by: marcopiraccini <[email protected]>
PR-URL: #62143
Fixes: #61740
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Paolo Insogna <[email protected]>
Reviewed-By: René <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
@github-actions github-actions Bot mentioned this pull request Nov 20, 2026
2026-11-30, Version 24.23.0 'Krypton' (LTS) #67663
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mcollina mcollina mcollina approved these changes
@ShogunPanda ShogunPanda ShogunPanda approved these changes
@MoLow MoLow MoLow approved these changes
@Renegade334 Renegade334 Renegade334 approved these changes
@trivikr trivikr trivikr approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

commit-queue-squash PRs the Commit Queue should land as one squashed commit. needs-ci PRs that need a full CI run. request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. watch-mode Issues and PRs related to watch mode.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

watch: NODE_OPTIONS=--watch causes infinite loop

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@marcopiraccini @Renegade334 @nodejs-github-bot @mcollina @ShogunPanda @MoLow @trivikr
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.