Fixes #126533: Make sure the ASAR path is always added for renderer processes

This commit is contained in:
Alexandru Dima 2021-06-18 17:07:43 +02:00
parent ed237e1138
commit 1dab1072ff
No known key found for this signature in database
GPG key ID: 6E58D7B045760DA0
5 changed files with 11 additions and 5 deletions

View file

@ -16,7 +16,7 @@ const bootstrapNode = require('./bootstrap-node');
bootstrapNode.removeGlobalNodeModuleLookupPaths();
// Enable ASAR in our forked processes
bootstrap.enableASARSupport(undefined);
bootstrap.enableASARSupport(undefined, false);
if (process.env['VSCODE_INJECT_NODE_MODULE_LOOKUP_PATH']) {
bootstrapNode.injectNodeModuleLookupPath(process.env['VSCODE_INJECT_NODE_MODULE_LOOKUP_PATH']);

View file

@ -82,7 +82,7 @@
}
// Enable ASAR support
globalThis.MonacoBootstrap.enableASARSupport(configuration.appRoot);
globalThis.MonacoBootstrap.enableASARSupport(configuration.appRoot, true);
// Get the nls configuration into the process.env as early as possible
const nlsConfig = globalThis.MonacoBootstrap.setupNLS();

8
src/bootstrap.js vendored
View file

@ -43,8 +43,9 @@
/**
* @param {string | undefined} appRoot
* @param {boolean} alwaysAddASARPath
*/
function enableASARSupport(appRoot) {
function enableASARSupport(appRoot, alwaysAddASARPath) {
if (!path || !Module || typeof process === 'undefined') {
console.warn('enableASARSupport() is only available in node.js environments'); // TODO@sandbox ASAR is currently non-sandboxed only
return;
@ -69,12 +70,17 @@
Module._resolveLookupPaths = function (request, parent) {
const paths = originalResolveLookupPaths(request, parent);
if (Array.isArray(paths)) {
let asarPathAdded = false;
for (let i = 0, len = paths.length; i < len; i++) {
if (paths[i] === NODE_MODULES_PATH) {
asarPathAdded = true;
paths.splice(i, 0, NODE_MODULES_ASAR_PATH);
break;
}
}
if (alwaysAddASARPath && !asarPathAdded) {
paths.push(NODE_MODULES_ASAR_PATH);
}
}
return paths;

View file

@ -17,7 +17,7 @@ bootstrap.avoidMonkeyPatchFromAppInsights();
bootstrapNode.configurePortable(product);
// Enable ASAR support
bootstrap.enableASARSupport(undefined);
bootstrap.enableASARSupport(undefined, false);
// Signal processes that we got launched as CLI
process.env['VSCODE_CLI'] = '1';

View file

@ -33,7 +33,7 @@ app.allowRendererProcessReuse = false;
const portable = bootstrapNode.configurePortable(product);
// Enable ASAR support
bootstrap.enableASARSupport(undefined);
bootstrap.enableASARSupport(undefined, false);
// Set userData path before app 'ready' event
const args = parseCLIArgs();