process: set up process warning handler in pre-execution
Since it depends on environment variables. PR-URL: https://github.com/nodejs/node/pull/26466 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
parent
f9b76c3bf4
commit
d7543a79d6
@ -115,12 +115,9 @@ if (isMainThread) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
onWarning,
|
|
||||||
emitWarning
|
emitWarning
|
||||||
} = NativeModule.require('internal/process/warning');
|
} = NativeModule.require('internal/process/warning');
|
||||||
if (!process.noProcessWarnings && process.env.NODE_NO_WARNINGS !== '1') {
|
|
||||||
process.on('warning', onWarning);
|
|
||||||
}
|
|
||||||
process.emitWarning = emitWarning;
|
process.emitWarning = emitWarning;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -8,6 +8,8 @@ let traceEventsAsyncHook;
|
|||||||
function prepareMainThreadExecution() {
|
function prepareMainThreadExecution() {
|
||||||
setupTraceCategoryState();
|
setupTraceCategoryState();
|
||||||
|
|
||||||
|
setupWarningHandler();
|
||||||
|
|
||||||
// Only main thread receives signals.
|
// Only main thread receives signals.
|
||||||
setupSignalHandlers();
|
setupSignalHandlers();
|
||||||
|
|
||||||
@ -36,6 +38,15 @@ function prepareMainThreadExecution() {
|
|||||||
loadPreloadModules();
|
loadPreloadModules();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setupWarningHandler() {
|
||||||
|
const {
|
||||||
|
onWarning
|
||||||
|
} = require('internal/process/warning');
|
||||||
|
if (!process.noProcessWarnings && process.env.NODE_NO_WARNINGS !== '1') {
|
||||||
|
process.on('warning', onWarning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function initializeReport() {
|
function initializeReport() {
|
||||||
if (!getOptionValue('--experimental-report')) {
|
if (!getOptionValue('--experimental-report')) {
|
||||||
return;
|
return;
|
||||||
@ -245,6 +256,7 @@ function loadPreloadModules() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
setupWarningHandler,
|
||||||
prepareMainThreadExecution,
|
prepareMainThreadExecution,
|
||||||
initializeDeprecations,
|
initializeDeprecations,
|
||||||
initializeESMLoader,
|
initializeESMLoader,
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
// message port.
|
// message port.
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
setupWarningHandler,
|
||||||
initializeDeprecations,
|
initializeDeprecations,
|
||||||
initializeESMLoader,
|
initializeESMLoader,
|
||||||
initializeFrozenIntrinsics,
|
initializeFrozenIntrinsics,
|
||||||
@ -39,6 +40,8 @@ const {
|
|||||||
const publicWorker = require('worker_threads');
|
const publicWorker = require('worker_threads');
|
||||||
const debug = require('util').debuglog('worker');
|
const debug = require('util').debuglog('worker');
|
||||||
|
|
||||||
|
setupWarningHandler();
|
||||||
|
|
||||||
debug(`[${threadId}] is setting up worker child environment`);
|
debug(`[${threadId}] is setting up worker child environment`);
|
||||||
|
|
||||||
// Set up the message port and start listening
|
// Set up the message port and start listening
|
||||||
|
Loading…
x
Reference in New Issue
Block a user