inspector: allow opening inspector when NODE_V8_COVERAGE is set

PR-URL: https://github.com/nodejs/node/pull/46113
Fixes: https://github.com/nodejs/node/issues/46110
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Moshe Atlow 2023-01-29 23:46:36 +02:00 committed by GitHub
parent d640feee85
commit 7b4cc58b70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 1 deletions

View File

@ -273,7 +273,7 @@ static void RegisterAsyncHookWrapper(const FunctionCallbackInfo<Value>& args) {
void IsEnabled(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
args.GetReturnValue().Set(InspectorEnabled(env));
args.GetReturnValue().Set(env->inspector_agent()->IsListening());
}
void Open(const FunctionCallbackInfo<Value>& args) {

14
test/fixtures/inspector-open.js vendored Normal file
View File

@ -0,0 +1,14 @@
const assert = require('assert');
const inspector = require('inspector');
assert.strictEqual(inspector.url(), undefined);
inspector.open(0, undefined, false);
assert(inspector.url().startsWith('ws://'));
assert.throws(() => {
inspector.open(0, undefined, false);
}, {
code: 'ERR_INSPECTOR_ALREADY_ACTIVATED'
});
inspector.close();
assert.strictEqual(inspector.url(), undefined);

View File

@ -0,0 +1,21 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const { spawnSync } = require('child_process');
const fixtures = require('../common/fixtures');
const tmpdir = require('../common/tmpdir');
common.skipIfInspectorDisabled();
common.skipIfWorker();
tmpdir.refresh();
let output = spawnSync(process.execPath, [fixtures.path('inspector-open.js')]);
assert.strictEqual(output.status, 0);
output = spawnSync(process.execPath, [fixtures.path('inspector-open.js')], {
env: { ...process.env, NODE_V8_COVERAGE: tmpdir.path },
});
assert.strictEqual(output.status, 0);