fix: limit the number of globals defined due to the v8 snapshot (#25051)

This commit is contained in:
Ryan Manuel
2022-12-08 09:35:58 -06:00
committed by GitHub
parent c540284f50
commit f9541aff10
7 changed files with 121 additions and 110 deletions

View File

@@ -287,6 +287,21 @@ const runIntegrityTest = async function (buildAppExecutable, buildAppDir, e2e) {
await testAlteringEntryPoint('console.log("simple alteration")', 'Integrity check failed with expected stack length 9 but got 10')
await testAlteringEntryPoint('console.log("accessing " + global.getSnapshotResult())', 'getSnapshotResult can only be called once')
function compareGlobals () {
const childProcess = require('child_process')
const nodeGlobalKeys = JSON.parse(childProcess.spawnSync('node -p "const x = Object.getOwnPropertyNames(global);JSON.stringify(x)"', { shell: true, encoding: 'utf8' }).stdout)
const extraKeys = Object.getOwnPropertyNames(global).filter((key) => {
return !nodeGlobalKeys.includes(key)
})
console.error(`extra keys in electron process: ${extraKeys}`)
}
const allowList = ['regeneratorRuntime', '__core-js_shared__', 'getSnapshotResult', 'supportTypeScript']
await testAlteringEntryPoint(`(${compareGlobals.toString()})()`, `extra keys in electron process: ${allowList}\nIntegrity check failed with expected stack length 9 but got 10`)
}
const test = async function (buildAppExecutable, buildAppDir) {