Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
process: set up process warning handler in pre-execution
Since it depends on environment variables.
  • Loading branch information
joyeecheung committed Mar 6, 2019
commit 0e97fa381d89ae3fe58d4da4b09b1e07ee3335bc
5 changes: 1 addition & 4 deletions lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 12 additions & 0 deletions lib/internal/bootstrap/pre_execution.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ let traceEventsAsyncHook;
function prepareMainThreadExecution() {
setupTraceCategoryState();

setupWarningHandler();

// Only main thread receives signals.
setupSignalHandlers();

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -231,6 +242,7 @@ function loadPreloadModules() {
}

module.exports = {
setupWarningHandler,
prepareMainThreadExecution,
initializeDeprecations,
initializeESMLoader,
Expand Down
3 changes: 3 additions & 0 deletions lib/internal/main/worker_thread.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// message port.

const {
setupWarningHandler,
initializeDeprecations,
initializeESMLoader,
initializeFrozenIntrinsics,
Expand Down Expand Up @@ -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
Expand Down