| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 57179a0 commit b1e739d
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,7 +38,6 @@ | |||
| 38 | 38 | ||
| 39 | 39 | const { internalBinding, NativeModule } = loaderExports; | |
| 40 | 40 | const { Object, Symbol } = primordials; | |
| 41 | - const { getOptionValue } = NativeModule.require('internal/options'); | ||
| 42 | 41 | const config = internalBinding('config'); | |
| 43 | 42 | const { deprecate } = NativeModule.require('internal/util'); | |
| 44 | 43 | ||
@@ -320,17 +319,6 @@ if (process.env.NODE_V8_COVERAGE) { | |||
| 320 | 319 | }; | |
| 321 | 320 | } | |
| 322 | 321 | ||
| 323 | - if (getOptionValue('--experimental-report')) { | ||
| 324 | - const { | ||
| 325 | - config, | ||
| 326 | - report, | ||
| 327 | - syncConfig | ||
| 328 | - } = NativeModule.require('internal/process/report'); | ||
| 329 | - process.report = report; | ||
| 330 | - // Download the CLI / ENV config into JS land. | ||
| 331 | - syncConfig(config, false); | ||
| 332 | - } | ||
| 333 | - | ||
| 334 | 322 | function setupProcessObject() { | |
| 335 | 323 | const EventEmitter = NativeModule.require('events'); | |
| 336 | 324 | const origProcProto = Object.getPrototypeOf(process); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,6 +11,10 @@ function prepareMainThreadExecution() { | |||
| 11 | 11 | // Only main thread receives signals. | |
| 12 | 12 | setupSignalHandlers(); | |
| 13 | 13 | ||
| 14 | + // Process initial configurations of node-report, if any. | ||
| 15 | + initializeReport(); | ||
| 16 | + initializeReportSignalHandlers(); // Main-thread-only. | ||
| 17 | + | ||
| 14 | 18 | // If the process is spawned with env NODE_CHANNEL_FD, it's probably | |
| 15 | 19 | // spawned by our child_process module, then initialize IPC. | |
| 16 | 20 | // This attaches some internal event listeners and creates: | |
@@ -31,6 +35,20 @@ function prepareMainThreadExecution() { | |||
| 31 | 35 | loadPreloadModules(); | |
| 32 | 36 | } | |
| 33 | 37 | ||
| 38 | + function initializeReport() { | ||
| 39 | + if (!getOptionValue('--experimental-report')) { | ||
| 40 | + return; | ||
| 41 | + } | ||
| 42 | + const { | ||
| 43 | + config, | ||
| 44 | + report, | ||
| 45 | + syncConfig | ||
| 46 | + } = require('internal/process/report'); | ||
| 47 | + process.report = report; | ||
| 48 | + // Download the CLI / ENV config into JS land. | ||
| 49 | + syncConfig(config, false); | ||
| 50 | + } | ||
| 51 | + | ||
| 34 | 52 | function setupSignalHandlers() { | |
| 35 | 53 | const { | |
| 36 | 54 | createSignalHandlers | |
@@ -41,15 +59,20 @@ function setupSignalHandlers() { | |||
| 41 | 59 | } = createSignalHandlers(); | |
| 42 | 60 | process.on('newListener', startListeningIfSignal); | |
| 43 | 61 | process.on('removeListener', stopListeningIfSignal); | |
| 62 | + } | ||
| 44 | 63 | ||
| 45 | - if (getOptionValue('--experimental-report')) { | ||
| 46 | - const { | ||
| 47 | - config, | ||
| 48 | - handleSignal | ||
| 49 | - } = require('internal/process/report'); | ||
| 50 | - if (config.events.includes('signal')) { | ||
| 51 | - process.on(config.signal, handleSignal); | ||
| 52 | - } | ||
| 64 | + // This has to be called after both initializeReport() and | ||
| 65 | + // setupSignalHandlers() are called | ||
| 66 | + function initializeReportSignalHandlers() { | ||
| 67 | + if (!getOptionValue('--experimental-report')) { | ||
| 68 | + return; | ||
| 69 | + } | ||
| 70 | + const { | ||
| 71 | + config, | ||
| 72 | + handleSignal | ||
| 73 | + } = require('internal/process/report'); | ||
| 74 | + if (config.events.includes('signal')) { | ||
| 75 | + process.on(config.signal, handleSignal); | ||
| 53 | 76 | } | |
| 54 | 77 | } | |
| 55 | 78 | ||
@@ -204,5 +227,6 @@ module.exports = { | |||
| 204 | 227 | initializeDeprecations, | |
| 205 | 228 | initializeESMLoader, | |
| 206 | 229 | loadPreloadModules, | |
| 207 | - setupTraceCategoryState | ||
| 230 | + setupTraceCategoryState, | ||
| 231 | + initializeReport | ||
| 208 | 232 | }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,6 +6,7 @@ | |||
| 6 | 6 | const { | |
| 7 | 7 | initializeDeprecations, | |
| 8 | 8 | initializeESMLoader, | |
| 9 | + initializeReport, | ||
| 9 | 10 | loadPreloadModules, | |
| 10 | 11 | setupTraceCategoryState | |
| 11 | 12 | } = require('internal/bootstrap/pre_execution'); | |
@@ -75,6 +76,7 @@ port.on('message', (message) => { | |||
| 75 | 76 | } = message; | |
| 76 | 77 | ||
| 77 | 78 | setupTraceCategoryState(); | |
| 79 | + initializeReport(); | ||
| 78 | 80 | if (manifestSrc) { | |
| 79 | 81 | require('internal/process/policy').setup(manifestSrc, manifestURL); | |
| 80 | 82 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments