Skip to content
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
13 changes: 12 additions & 1 deletion lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,18 @@ if (process.env.NODE_V8_COVERAGE) {
}

if (getOptionValue('--experimental-report')) {
NativeModule.require('internal/process/report').setup();
const {
config,
handleSignal,
report,
syncConfig
} = NativeModule.require('internal/process/report');
process.report = report;
// Download the CLI / ENV config into JS land.
syncConfig(config, false);
if (config.events.includes('signal')) {
process.on(config.signal, handleSignal);
}
}

function setupTraceCategoryState() {
Expand Down
18 changes: 8 additions & 10 deletions lib/internal/process/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
const { emitExperimentalWarning } = require('internal/util');
const {
ERR_INVALID_ARG_TYPE,
ERR_SYNTHETIC } = require('internal/errors').codes;
ERR_SYNTHETIC
} = require('internal/errors').codes;

exports.setup = function() {
const REPORTEVENTS = 1;
const REPORTSIGNAL = 2;
const REPORTFILENAME = 3;
Expand Down Expand Up @@ -127,19 +127,12 @@ exports.setup = function() {
}
};

// Download the CLI / ENV config into JS land.
nr.syncConfig(config, false);

function handleSignal(signo) {
if (typeof signo !== 'string')
signo = config.signal;
nr.onUserSignal(signo);
}

if (config.events.includes('signal')) {
process.on(config.signal, handleSignal);
}

function parseOptions(obj) {
const list = [];
if (obj == null)
Expand All @@ -156,5 +149,10 @@ exports.setup = function() {
list.push(REPORTVERBOSE);
return list;
}
process.report = report;

module.exports = {
config,
handleSignal,
report,
syncConfig: nr.syncConfig
};