Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

process: add CLI opt to hide experimental warnings #31000

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,14 @@ added: v0.8.0

Silence deprecation warnings.

### `--no-experimental-warnings`
<!-- YAML
added: REPLACEME
-->

Silence all experimental process warnings. These are emitted when using
features which are considered experimental.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
features which are considered experimental.
features which are experimental.

Copy link
Member

Choose a reason for hiding this comment

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

Might want to add an explicit warning against using in production and/or a link to the definition of experimental elsewhere in the docs. But if that doesn't happen hear, it can happen in a subsequent PR. Not a blocking comment.


### `--no-force-async-hooks-checks`
<!-- YAML
added: v9.0.0
Expand Down Expand Up @@ -1111,6 +1119,7 @@ Node.js options that are allowed are:
* `--max-http-header-size`
* `--napi-modules`
* `--no-deprecation`
* `--no-experimental-warnings`
* `--no-force-async-hooks-checks`
* `--no-warnings`
* `--openssl-config`
Expand Down
2 changes: 2 additions & 0 deletions lib/internal/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ function slowCases(enc) {
}

function emitExperimentalWarning(feature) {
const { getOptionValue } = require('internal/options');
if (getOptionValue('--no-experimental-warnings')) return;
if (experimentalWarnings.has(feature)) return;
const msg = `${feature} is an experimental feature. This feature could ` +
'change at any time';
Expand Down
4 changes: 4 additions & 0 deletions src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,10 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
"silence all process warnings",
&EnvironmentOptions::no_warnings,
kAllowedInEnvironment);
AddOption("--no-experimental-warnings",
"silence all experimental process warnings",
&EnvironmentOptions::no_experimental_warnings,
kAllowedInEnvironment);
Copy link
Member

Choose a reason for hiding this comment

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

If this did move forward, it should not be permitted within NODE_OPTIONS

AddOption("--force-context-aware",
"disable loading non-context-aware addons",
&EnvironmentOptions::force_context_aware,
Expand Down
1 change: 1 addition & 0 deletions src/node_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class EnvironmentOptions : public Options {
bool no_deprecation = false;
bool no_force_async_hooks_checks = false;
bool no_warnings = false;
bool no_experimental_warnings = false;
bool force_context_aware = false;
bool pending_deprecation = false;
bool preserve_symlinks = false;
Expand Down
16 changes: 16 additions & 0 deletions test/parallel/test-process-no-emit-experimental-warnings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Flags: --no-experimental-warnings --expose-internals
'use strict';
// Test supressing experimental warnings.
const common = require('../common');
const { hijackStderr,
restoreStderr
} = require('../common/hijackstdio');
const { emitExperimentalWarning } = require('internal/util');

function test() {
hijackStderr(common.mustNotCall('stderr.write must not be called'));
emitExperimentalWarning('testExperimentalWarning');
restoreStderr();
}

test();