Browse Source

fix: do not remove node globals when context isolation is enabled (#18967)

Samuel Attard 5 years ago
parent
commit
6eed4a98ce
1 changed files with 11 additions and 8 deletions
  1. 11 8
      lib/renderer/init.ts

+ 11 - 8
lib/renderer/init.ts

@@ -179,14 +179,17 @@ if (nodeIntegration) {
     }
   }
 } else {
-  // Delete Node's symbols after the Environment has been loaded.
-  process.once('loaded', function () {
-    delete global.process
-    delete global.Buffer
-    delete global.setImmediate
-    delete global.clearImmediate
-    delete global.global
-  })
+  // Delete Node's symbols after the Environment has been loaded in a
+  // non context-isolated environment
+  if (!contextIsolation) {
+    process.once('loaded', function () {
+      delete global.process
+      delete global.Buffer
+      delete global.setImmediate
+      delete global.clearImmediate
+      delete global.global
+    })
+  }
 }
 
 const errorUtils = require('@electron/internal/common/error-utils')