fix: do not register the node ESM loader in renderer processes (#24301)
This commit is contained in:
parent
e4180b3a3a
commit
d8be385d4b
5 changed files with 32 additions and 5 deletions
|
@ -41,3 +41,4 @@ test_account_for_non-node_basename.patch
|
||||||
lib_src_switch_buffer_kmaxlength_to_size_t.patch
|
lib_src_switch_buffer_kmaxlength_to_size_t.patch
|
||||||
update_tests_after_increasing_typed_array_size.patch
|
update_tests_after_increasing_typed_array_size.patch
|
||||||
darwin_work_around_clock_jumping_back_in_time.patch
|
darwin_work_around_clock_jumping_back_in_time.patch
|
||||||
|
fix_do_not_register_the_esm_loader_in_renderer_processes.patch
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Samuel Attard <samuel.r.attard@gmail.com>
|
||||||
|
Date: Thu, 25 Jun 2020 09:29:04 -0700
|
||||||
|
Subject: fix: do not register the ESM loader in renderer processes
|
||||||
|
|
||||||
|
Only one ESM loader can be registered per isolate, in renderer processes this should be blink. This patches node so that it won't register it's handler (overriding blinks) in non-browser processes.
|
||||||
|
|
||||||
|
This has been upstreamed in:
|
||||||
|
* https://github.com/nodejs/node/pull/34060
|
||||||
|
* https://github.com/nodejs/node/pull/34127
|
||||||
|
|
||||||
|
We can't easily rebase on that accepted solution here but we can as soon as we upgrade to
|
||||||
|
Node.js v14, since we need to leverage the new version of node::CreateEnvironment
|
||||||
|
introduced in https://github.com/nodejs/node/pull/30467.
|
||||||
|
|
||||||
|
diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js
|
||||||
|
index b4a0f71af5853f427a10449b52509052fbe3facd..ba5b0b6e51bcddbc5b9dd9c31231585d61b131a0 100644
|
||||||
|
--- a/lib/internal/bootstrap/pre_execution.js
|
||||||
|
+++ b/lib/internal/bootstrap/pre_execution.js
|
||||||
|
@@ -411,6 +411,9 @@ function initializeESMLoader() {
|
||||||
|
// Create this WeakMap in js-land because V8 has no C++ API for WeakMap.
|
||||||
|
internalBinding('module_wrap').callbackMap = new SafeWeakMap();
|
||||||
|
|
||||||
|
+ // Do not hook the ESM loader in renderer processes as it overrides blinks loader
|
||||||
|
+ if (typeof process.type === 'string' && process.type !== 'browser') return;
|
||||||
|
+
|
||||||
|
const {
|
||||||
|
setImportModuleDynamicallyCallback,
|
||||||
|
setInitializeImportMetaObjectCallback
|
|
@ -73,9 +73,6 @@ steps:
|
||||||
sudo gdk-pixbuf-query-loaders --update-cache
|
sudo gdk-pixbuf-query-loaders --update-cache
|
||||||
cd src
|
cd src
|
||||||
export ELECTRON_OUT_DIR=Default
|
export ELECTRON_OUT_DIR=Default
|
||||||
unset ELECTRON_DISABLE_SANDBOX
|
|
||||||
sudo chown root out/Default/chrome-sandbox
|
|
||||||
sudo chmod 4755 out/Default/chrome-sandbox
|
|
||||||
(cd electron && node script/yarn test -- --enable-logging)
|
(cd electron && node script/yarn test -- --enable-logging)
|
||||||
displayName: 'Run Electron tests'
|
displayName: 'Run Electron tests'
|
||||||
timeoutInMinutes: 20
|
timeoutInMinutes: 20
|
||||||
|
|
|
@ -2,7 +2,7 @@ resources:
|
||||||
containers:
|
containers:
|
||||||
- container: arm32v7-test-container
|
- container: arm32v7-test-container
|
||||||
image: electronjs/build:arm32v7-697b894f36d127155e020f4e8ad4b2e5f6a09613
|
image: electronjs/build:arm32v7-697b894f36d127155e020f4e8ad4b2e5f6a09613
|
||||||
options: --shm-size 128m --cap-add SYS_ADMIN
|
options: --shm-size 128m
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
- job: Test_Arm32v7
|
- job: Test_Arm32v7
|
||||||
|
|
|
@ -2,7 +2,7 @@ resources:
|
||||||
containers:
|
containers:
|
||||||
- container: arm64v8-test-container
|
- container: arm64v8-test-container
|
||||||
image: electronjs/build:arm64v8-697b894f36d127155e020f4e8ad4b2e5f6a09613
|
image: electronjs/build:arm64v8-697b894f36d127155e020f4e8ad4b2e5f6a09613
|
||||||
options: --shm-size 128m --cap-add SYS_ADMIN
|
options: --shm-size 128m
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
- job: Test_Arm64
|
- job: Test_Arm64
|
||||||
|
|
Loading…
Reference in a new issue