process: delay process.argv[0] and process.argv0 handling
Since these depends on process runtime states, delay them until pre-execution. PR-URL: https://github.com/nodejs/node/pull/26517 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
parent
eb0bf8d307
commit
728c939e57
@ -214,13 +214,6 @@ if (!config.noBrowserGlobals) {
|
||||
|
||||
setupDOMException();
|
||||
|
||||
Object.defineProperty(process, 'argv0', {
|
||||
enumerable: true,
|
||||
configurable: false,
|
||||
value: process.argv[0]
|
||||
});
|
||||
process.argv[0] = process.execPath;
|
||||
|
||||
// process.allowedNodeEnvironmentFlags
|
||||
Object.defineProperty(process, 'allowedNodeEnvironmentFlags', {
|
||||
get() {
|
||||
|
@ -6,6 +6,8 @@ const { getOptionValue } = require('internal/options');
|
||||
let traceEventsAsyncHook;
|
||||
|
||||
function prepareMainThreadExecution() {
|
||||
// Patch the process object with legacy properties and normalizations
|
||||
patchProcessObject();
|
||||
setupTraceCategoryState();
|
||||
|
||||
setupWarningHandler();
|
||||
@ -48,6 +50,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
|
||||
@ -296,6 +307,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');
|
||||
|
Loading…
x
Reference in New Issue
Block a user