Skip to content

Conversation

@islandryu
Copy link
Member

When using negated options for boolean options that imply other options (e.g., --inspect-brk), the implied options are not removed as expected. This causes the implied option to remain active, leading to unexpected behavior.

shimaryuuheinoMac-mini:node shimaryuuhei$ node --inspect-brk --no-inspect-brk -e "console.log(\"foo\")"
Debugger listening on ws://127.0.0.1:9229/67479127-5d17-4027-b514-70217b2fe102
For help, see: https://nodejs.org/en/docs/inspector
foo

When using --no-inspect-brk, only the effect of the --inspect option remains.

This change ensures that when a negated option (e.g., --no-...) is used, any implied options are also removed. After this fix, the above example will no longer activate the implied options.

Alternative

Currently, the negated options affected by this change are not documented in the official CLI documentation: https://nodejs.org/api/cli.html

An alternative approach could be to remove these undocumented negated options entirely, ensuring no unexpected behavior arises from their usage.

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Dec 19, 2024
Comment on lines 391 to 396
std::string implied_name = name;
if (is_negation) {
// Implications for negated options are defined with "--no-".
implied_name.insert(2, "no-");
}
auto implications = implications_.equal_range(implied_name);
Copy link
Member Author

Choose a reason for hiding this comment

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

Before the fix, there was likely code intended to apply negations to implications as well, but options with the --no- prefix were never added to the implications_.

@codecov
Copy link

codecov bot commented Dec 19, 2024

Codecov Report

❌ Patch coverage is 80.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.52%. Comparing base (842448b) to head (7ff865b).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/node_options-inl.h 80.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #56313      +/-   ##
==========================================
+ Coverage   88.00%   88.52%   +0.51%     
==========================================
  Files         704      704              
  Lines      208739   208744       +5     
  Branches    40196    40276      +80     
==========================================
+ Hits       183706   184782    +1076     
+ Misses      16992    15970    -1022     
+ Partials     8041     7992      -49     
Files with missing lines Coverage Δ
src/node_options-inl.h 83.06% <80.00%> (-0.07%) ⬇️

... and 104 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.

@avivkeller
Copy link
Member

@islandryu Can you please rebase? Also, is this semver-major? It does change existing functionality

@islandryu islandryu force-pushed the fix/nagativeOptions branch from 6425807 to 4559f70 Compare January 8, 2026 05:56
@avivkeller avivkeller added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. review wanted PRs that need reviews. request-ci Add this label to start a Jenkins CI on a PR. labels Jan 8, 2026
Comment on lines +435 to +437
default_field_map[value.name] =
*value.target_field
->template Lookup<bool>(options);
Copy link
Member Author

@islandryu islandryu Jan 8, 2026

Choose a reason for hiding this comment

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

I changed it so that it sets a default value instead of simply toggling a boolean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. request-ci Add this label to start a Jenkins CI on a PR. review wanted PRs that need reviews.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants