Skip to content
Permalink
Browse files

process: delay process.argv[0] and process.argv0 handling

Since these depends on process runtime states, delay them until
pre-execution.

PR-URL: #26517
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information...
joyeecheung authored and targos committed Mar 8, 2019
1 parent 03bd649 commit d4f95091d074adfcf79e1f7d64f5e8b599a5f9f0
Showing with 14 additions and 7 deletions.
  1. +0 −7 lib/internal/bootstrap/node.js
  2. +12 −0 lib/internal/bootstrap/pre_execution.js
  3. +2 −0 lib/internal/main/worker_thread.js
@@ -206,13 +206,6 @@ if (!config.noBrowserGlobals) {
defineOperation(global, 'setImmediate', timers.setImmediate);
}

Object.defineProperty(process, 'argv0', {
enumerable: true,
configurable: false,
value: process.argv[0]
});
process.argv[0] = process.execPath;

// TODO(jasnell): The following have been globals since around 2012.
// That's just silly. The underlying perfctr support has been removed
// so these are now deprecated non-ops that can be removed after one
@@ -3,6 +3,8 @@
const { getOptionValue } = require('internal/options');

function prepareMainThreadExecution() {
// Patch the process object with legacy properties and normalizations
patchProcessObject();
setupTraceCategoryState();

setupWarningHandler();
@@ -59,6 +61,15 @@ function prepareMainThreadExecution() {
loadPreloadModules();
}

function patchProcessObject() {
Object.defineProperty(process, 'argv0', {
enumerable: true,
configurable: false,
value: process.argv[0]
});
process.argv[0] = process.execPath;
}

function setupWarningHandler() {
const {
onWarning
@@ -307,6 +318,7 @@ function loadPreloadModules() {
}

module.exports = {
patchProcessObject,
setupCoverageHooks,
setupWarningHandler,
setupDebugEnv,
@@ -4,6 +4,7 @@
// message port.

const {
patchProcessObject,
setupCoverageHooks,
setupWarningHandler,
setupDebugEnv,
@@ -41,6 +42,7 @@ const {

const publicWorker = require('worker_threads');

patchProcessObject();
setupDebugEnv();

const debug = require('util').debuglog('worker');

0 comments on commit d4f9509

Please sign in to comment.
You can’t perform that action at this time.