process: set up process warning handler in pre-execution · nodejs/node@cc606e2 (original) (raw)
3 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -115,12 +115,9 @@ if (isMainThread) { | ||
115 | 115 | } |
116 | 116 | |
117 | 117 | const { |
118 | - onWarning, | |
119 | 118 | emitWarning |
120 | 119 | } = NativeModule.require('internal/process/warning'); |
121 | -if (!process.noProcessWarnings && process.env.NODE_NO_WARNINGS !== '1') { | |
122 | -process.on('warning', onWarning); | |
123 | -} | |
120 | + | |
124 | 121 | process.emitWarning = emitWarning; |
125 | 122 | |
126 | 123 | const { |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -8,6 +8,8 @@ let traceEventsAsyncHook; | ||
8 | 8 | function prepareMainThreadExecution() { |
9 | 9 | setupTraceCategoryState(); |
10 | 10 | |
11 | +setupWarningHandler(); | |
12 | + | |
11 | 13 | // Only main thread receives signals. |
12 | 14 | setupSignalHandlers(); |
13 | 15 | |
@@ -36,6 +38,15 @@ function prepareMainThreadExecution() { | ||
36 | 38 | loadPreloadModules(); |
37 | 39 | } |
38 | 40 | |
41 | +function setupWarningHandler() { | |
42 | +const { | |
43 | + onWarning | |
44 | +} = require('internal/process/warning'); | |
45 | +if (!process.noProcessWarnings && process.env.NODE_NO_WARNINGS !== '1') { | |
46 | +process.on('warning', onWarning); | |
47 | +} | |
48 | +} | |
49 | + | |
39 | 50 | function initializeReport() { |
40 | 51 | if (!getOptionValue('--experimental-report')) { |
41 | 52 | return; |
@@ -251,6 +262,7 @@ function loadPreloadModules() { | ||
251 | 262 | } |
252 | 263 | |
253 | 264 | module.exports = { |
265 | + setupWarningHandler, | |
254 | 266 | prepareMainThreadExecution, |
255 | 267 | initializeDeprecations, |
256 | 268 | initializeESMLoader, |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -4,6 +4,7 @@ | ||
4 | 4 | // message port. |
5 | 5 | |
6 | 6 | const { |
7 | + setupWarningHandler, | |
7 | 8 | initializeDeprecations, |
8 | 9 | initializeESMLoader, |
9 | 10 | initializeFrozenIntrinsics, |
@@ -39,6 +40,8 @@ const { | ||
39 | 40 | const publicWorker = require('worker_threads'); |
40 | 41 | const debug = require('util').debuglog('worker'); |
41 | 42 | |
43 | +setupWarningHandler(); | |
44 | + | |
42 | 45 | debug(`[${threadId}] is setting up worker child environment`); |
43 | 46 | |
44 | 47 | // Set up the message port and start listening |