process: move process mutation into bootstrap/node.js
This patch moves the part in the report initialization that mutates the process object into bootstrap/node.js so it's easier to tell the side effect of the initialization on the global state during bootstrap. PR-URL: https://github.com/nodejs/node/pull/25821 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
parent
c2359bdad6
commit
406329de57
@ -309,7 +309,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() {
|
||||
|
@ -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;
|
||||
@ -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)
|
||||
@ -156,5 +149,10 @@ exports.setup = function() {
|
||||
list.push(REPORTVERBOSE);
|
||||
return list;
|
||||
}
|
||||
process.report = report;
|
||||
|
||||
module.exports = {
|
||||
config,
|
||||
handleSignal,
|
||||
report,
|
||||
syncConfig: nr.syncConfig
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user