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

lib: remove internalBinding('config').pendingDeprecation #24962

Closed
wants to merge 2 commits 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
6 changes: 2 additions & 4 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ const {
isArrayBufferView,
isUint8Array
} = require('internal/util/types');
const {
pendingDeprecation
} = internalBinding('config');

const {
ERR_BUFFER_OUT_OF_BOUNDS,
ERR_OUT_OF_RANGE,
Expand Down Expand Up @@ -138,7 +136,7 @@ const bufferWarning = 'Buffer() is deprecated due to security and usability ' +
function showFlaggedDeprecation() {
if (bufferWarningAlreadyEmitted ||
++nodeModulesCheckCounter > 10000 ||
(!pendingDeprecation &&
(!require('internal/options').getOptionValue('--pending-deprecation') &&
BridgeAR marked this conversation as resolved.
Show resolved Hide resolved
isInsideNodeModules())) {
// We don't emit a warning, because we either:
// - Already did so, or
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ function startup() {
{
// Install legacy getters on the `util` binding for typechecking.
// TODO(addaleax): Turn into a full runtime deprecation.
const { pendingDeprecation } = internalBinding('config');
const pendingDeprecation = getOptionValue('--pending-deprecation');
const utilBinding = internalBinding('util');
const types = internalBinding('types');
for (const name of [
Expand Down
3 changes: 0 additions & 3 deletions src/node_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ static void Initialize(Local<Object> target,
if (env->options()->experimental_repl_await)
READONLY_TRUE_PROPERTY(target, "experimentalREPLAwait");

if (env->options()->pending_deprecation)
READONLY_TRUE_PROPERTY(target, "pendingDeprecation");

if (env->options()->expose_internals)
READONLY_TRUE_PROPERTY(target, "exposeInternals");

Expand Down
32 changes: 21 additions & 11 deletions test/parallel/test-pending-deprecation.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,53 @@
'use strict';

// Tests that --pending-deprecation and NODE_PENDING_DEPRECATION both
// set the process.binding('config').pendingDeprecation flag that is
// used to determine if pending deprecation messages should be shown.
// The test is performed by launching two child processes that run
// Flags: --expose-internals
// Tests that --pending-deprecation and NODE_PENDING_DEPRECATION both set the
// `require('internal/options').getOptionValue('--pending-deprecation')`
// flag that is used to determine if pending deprecation messages should be
// shown. The test is performed by launching two child processes that run
// this same test script with different arguments. If those exit with
// code 0, then the test passes. If they don't, it fails.

// TODO(joyeecheung): instead of testing internals, test the actual features
// pending deprecations.

const common = require('../common');

const assert = require('assert');
const config = process.binding('config');
const fork = require('child_process').fork;
const { getOptionValue } = require('internal/options');

function message(name) {
return `${name} did not set the process.binding('config').` +
'pendingDeprecation flag.';
return `${name} did not affect getOptionValue('--pending-deprecation')`;
}

switch (process.argv[2]) {
case 'env':
case 'switch':
assert.strictEqual(config.pendingDeprecation, true);
assert.strictEqual(
getOptionValue('--pending-deprecation'),
true
);
break;
default:
// Verify that the flag is off by default.
const envvar = process.env.NODE_PENDING_DEPRECATION;
assert.strictEqual(config.pendingDeprecation, envvar && envvar[0] === '1');
assert.strictEqual(
getOptionValue('--pending-deprecation'),
!!(envvar && envvar[0] === '1')
);

// Test the --pending-deprecation command line switch.
fork(__filename, ['switch'], {
execArgv: ['--pending-deprecation'],
execArgv: ['--pending-deprecation', '--expose-internals'],
silent: true
}).on('exit', common.mustCall((code) => {
assert.strictEqual(code, 0, message('--pending-deprecation'));
}));

// Test the --pending_deprecation command line switch.
fork(__filename, ['switch'], {
execArgv: ['--pending_deprecation'],
execArgv: ['--pending_deprecation', '--expose-internals'],
silent: true
}).on('exit', common.mustCall((code) => {
assert.strictEqual(code, 0, message('--pending_deprecation'));
Expand All @@ -47,6 +56,7 @@ switch (process.argv[2]) {
// Test the NODE_PENDING_DEPRECATION environment var.
fork(__filename, ['env'], {
env: Object.assign({}, process.env, { NODE_PENDING_DEPRECATION: 1 }),
execArgv: ['--expose-internals'],
silent: true
}).on('exit', common.mustCall((code) => {
assert.strictEqual(code, 0, message('NODE_PENDING_DEPRECATION'));
Expand Down