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

src: remove process.binding('config').debugOptions #25999

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
15 changes: 0 additions & 15 deletions src/node_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

namespace node {

using v8::Boolean;
using v8::Context;
using v8::Integer;
using v8::Isolate;
using v8::Local;
using v8::Number;
Expand Down Expand Up @@ -72,19 +70,6 @@ static void Initialize(Local<Object> target,
READONLY_PROPERTY(target,
"bits",
Number::New(env->isolate(), 8 * sizeof(intptr_t)));

Local<Object> debug_options_obj = Object::New(isolate);
READONLY_PROPERTY(target, "debugOptions", debug_options_obj);

const DebugOptions& debug_options = env->options()->debug_options();
READONLY_PROPERTY(debug_options_obj,
"inspectorEnabled",
Boolean::New(isolate, debug_options.inspector_enabled));
READONLY_STRING_PROPERTY(
debug_options_obj, "host", debug_options.host_port.host());
READONLY_PROPERTY(debug_options_obj,
"port",
Integer::New(isolate, debug_options.host_port.port()));
} // InitConfig

} // namespace node
Expand Down
150 changes: 78 additions & 72 deletions test/sequential/test-inspector-port-cluster.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

// Flags: --expose-internals

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

common.skipIfInspectorDisabled();
Expand Down Expand Up @@ -205,7 +207,7 @@ function testRunnerMain() {
}
function masterProcessMain() {
const workers = JSON.parse(process.env.workers);
const clusterSettings = JSON.parse(process.env.clusterSettings);
const clusterSettings = JSON.parse(process.env.clusterSettings) || {};
const badPortError = { type: RangeError, code: 'ERR_SOCKET_BAD_PORT' };
let debugPort = process.debugPort;

Expand All @@ -224,85 +226,89 @@ function masterProcessMain() {
params.expectedHost = worker.expectedHost;
}

if (clusterSettings) {
if (clusterSettings.inspectPort === 'addTwo') {
clusterSettings.inspectPort = common.mustCall(
() => { return debugPort += 2; },
workers.length
);
} else if (clusterSettings.inspectPort === 'string') {
clusterSettings.inspectPort = 'string';
cluster.setupMaster(clusterSettings);

common.expectsError(() => {
cluster.fork(params).on('exit', common.mustCall(checkExitCode));
}, badPortError);

return;
} else if (clusterSettings.inspectPort === 'null') {
clusterSettings.inspectPort = null;
cluster.setupMaster(clusterSettings);

common.expectsError(() => {
cluster.fork(params).on('exit', common.mustCall(checkExitCode));
}, badPortError);

return;
} else if (clusterSettings.inspectPort === 'bignumber') {
clusterSettings.inspectPort = 1293812;
cluster.setupMaster(clusterSettings);

common.expectsError(() => {
cluster.fork(params).on('exit', common.mustCall(checkExitCode));
}, badPortError);

return;
} else if (clusterSettings.inspectPort === 'negativenumber') {
clusterSettings.inspectPort = -9776;
cluster.setupMaster(clusterSettings);

common.expectsError(() => {
cluster.fork(params).on('exit', common.mustCall(checkExitCode));
}, badPortError);

return;
} else if (clusterSettings.inspectPort === 'bignumberfunc') {
clusterSettings.inspectPort = common.mustCall(
() => 123121,
workers.length
);

cluster.setupMaster(clusterSettings);

common.expectsError(() => {
cluster.fork(params).on('exit', common.mustCall(checkExitCode));
}, badPortError);

return;
} else if (clusterSettings.inspectPort === 'strfunc') {
clusterSettings.inspectPort = common.mustCall(
() => 'invalidPort',
workers.length
);

cluster.setupMaster(clusterSettings);

common.expectsError(() => {
cluster.fork(params).on('exit', common.mustCall(checkExitCode));
}, badPortError);

return;
}
clusterSettings.execArgv = clusterSettings.execArgv ?
clusterSettings.execArgv.concat(['--expose-internals']) :
process.execArgv.concat(['--expose-internals']);

if (clusterSettings.inspectPort === 'addTwo') {
clusterSettings.inspectPort = common.mustCall(
() => { return debugPort += 2; },
workers.length
);
} else if (clusterSettings.inspectPort === 'string') {
clusterSettings.inspectPort = 'string';
cluster.setupMaster(clusterSettings);

common.expectsError(() => {
cluster.fork(params).on('exit', common.mustCall(checkExitCode));
}, badPortError);

return;
} else if (clusterSettings.inspectPort === 'null') {
clusterSettings.inspectPort = null;
cluster.setupMaster(clusterSettings);

common.expectsError(() => {
cluster.fork(params).on('exit', common.mustCall(checkExitCode));
}, badPortError);

return;
} else if (clusterSettings.inspectPort === 'bignumber') {
clusterSettings.inspectPort = 1293812;
cluster.setupMaster(clusterSettings);

common.expectsError(() => {
cluster.fork(params).on('exit', common.mustCall(checkExitCode));
}, badPortError);

return;
} else if (clusterSettings.inspectPort === 'negativenumber') {
clusterSettings.inspectPort = -9776;
cluster.setupMaster(clusterSettings);

common.expectsError(() => {
cluster.fork(params).on('exit', common.mustCall(checkExitCode));
}, badPortError);

return;
} else if (clusterSettings.inspectPort === 'bignumberfunc') {
clusterSettings.inspectPort = common.mustCall(
() => 123121,
workers.length
);

cluster.setupMaster(clusterSettings);

common.expectsError(() => {
cluster.fork(params).on('exit', common.mustCall(checkExitCode));
}, badPortError);

return;
} else if (clusterSettings.inspectPort === 'strfunc') {
clusterSettings.inspectPort = common.mustCall(
() => 'invalidPort',
workers.length
);

cluster.setupMaster(clusterSettings);

common.expectsError(() => {
cluster.fork(params).on('exit', common.mustCall(checkExitCode));
}, badPortError);

return;
}

cluster.setupMaster(clusterSettings);

cluster.fork(params).on('exit', common.mustCall(checkExitCode));
}
}

function workerProcessMain() {
const { expectedPort, expectedInitialPort, expectedHost } = process.env;
const debugOptions = process.binding('config').debugOptions;
const debugOptions =
require('internal/options').getOptionValue('--inspect-port');

if ('expectedPort' in process.env) {
assert.strictEqual(process.debugPort, +expectedPort);
Expand All @@ -327,7 +333,7 @@ function spawnMaster({ execArgv, workers, clusterSettings = {} }) {
clusterSettings: JSON.stringify(clusterSettings),
testProcess: true
}),
execArgv
execArgv: execArgv.concat(['--expose-internals'])
}).on('exit', common.mustCall((code, signal) => {
checkExitCode(code, signal);
resolve();
Expand Down