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 {
|
||||
onWarning,
|
||||
emitWarning
|
||||
} = NativeModule.require('internal/process/warning');
|
||||
if (!process.noProcessWarnings && process.env.NODE_NO_WARNINGS !== '1') {
|
||||
process.on('warning', onWarning);
|
||||
}
|
||||
|
||||
process.emitWarning = emitWarning;
|
||||
|
||||
const {
|
||||
|
@ -8,6 +8,8 @@ let traceEventsAsyncHook;
|
||||
function prepareMainThreadExecution() {
|
||||
setupTraceCategoryState();
|
||||
|
||||
setupWarningHandler();
|
||||
|
||||
// Only main thread receives signals.
|
||||
setupSignalHandlers();
|
||||
|
||||
@ -36,6 +38,15 @@ function prepareMainThreadExecution() {
|
||||
loadPreloadModules();
|
||||
}
|
||||
|
||||
function setupWarningHandler() {
|
||||
const {
|
||||
onWarning
|
||||
} = require('internal/process/warning');
|
||||
if (!process.noProcessWarnings && process.env.NODE_NO_WARNINGS !== '1') {
|
||||
process.on('warning', onWarning);
|
||||
}
|
||||
}
|
||||
|
||||
function initializeReport() {
|
||||
if (!getOptionValue('--experimental-report')) {
|
||||
return;
|
||||
@ -245,6 +256,7 @@ function loadPreloadModules() {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
setupWarningHandler,
|
||||
prepareMainThreadExecution,
|
||||
initializeDeprecations,
|
||||
initializeESMLoader,
|
||||
|
@ -4,6 +4,7 @@
|
||||
// message port.
|
||||
|
||||
const {
|
||||
setupWarningHandler,
|
||||
initializeDeprecations,
|
||||
initializeESMLoader,
|
||||
initializeFrozenIntrinsics,
|
||||
@ -39,6 +40,8 @@ const {
|
||||
const publicWorker = require('worker_threads');
|
||||
const debug = require('util').debuglog('worker');
|
||||
|
||||
setupWarningHandler();
|
||||
|
||||
debug(`[${threadId}] is setting up worker child environment`);
|
||||
|
||||
// Set up the message port and start listening
|
||||
|
Loading…
x
Reference in New Issue
Block a user