fix: initialize asar support in worker threads (#33216)
* fix: initialize asar support in worker threads Use `ObjectWrap` instead of gin's Wrap in `electron_api_asar.cc` because gin isn't fully initialized (and apparently not possible to initialize without ruining the isolate configuration and array buffer allocator) in worker threads. In the worker thread call `setupAsarSupport` just as we do for the main process. * Update lib/asar/fs-wrapper.ts Co-authored-by: Darshan Sen <raisinten@gmail.com> * Update patches/node/worker_thread_add_asar_support.patch Co-authored-by: Darshan Sen <raisinten@gmail.com> * Add a test Co-authored-by: Darshan Sen <raisinten@gmail.com> Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
This commit is contained in:
parent
27ddf19f3c
commit
06a00b74e8
8 changed files with 209 additions and 70 deletions
|
@ -34,3 +34,4 @@ darwin_bump_minimum_supported_version_to_10_15_3406.patch
|
|||
fix_failing_node_js_test_on_outdated.patch
|
||||
be_compatible_with_cppgc.patch
|
||||
feat_add_knostartdebugsignalhandler_to_environment_to_prevent.patch
|
||||
worker_thread_add_asar_support.patch
|
||||
|
|
41
patches/node/worker_thread_add_asar_support.patch
Normal file
41
patches/node/worker_thread_add_asar_support.patch
Normal file
|
@ -0,0 +1,41 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fedor Indutny <indutny@signal.org>
|
||||
Date: Wed, 9 Mar 2022 17:52:32 -0800
|
||||
Subject: worker_thread: add asar support
|
||||
|
||||
This patch initializes asar support in workers threads in
|
||||
Node.js.
|
||||
|
||||
diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js
|
||||
index 419ffd9d5deb84eb94381259d3084411f6c3341b..17a1860d158976f11035553601560d171c7fc25a 100644
|
||||
--- a/lib/internal/bootstrap/pre_execution.js
|
||||
+++ b/lib/internal/bootstrap/pre_execution.js
|
||||
@@ -505,6 +505,7 @@ module.exports = {
|
||||
loadPreloadModules,
|
||||
setupTraceCategoryState,
|
||||
setupInspectorHooks,
|
||||
+ setupAsarSupport,
|
||||
initializeReport,
|
||||
initializeCJSLoader,
|
||||
initializeWASI
|
||||
diff --git a/lib/internal/main/worker_thread.js b/lib/internal/main/worker_thread.js
|
||||
index e3ce67987ee3185a93750ebad72beab304c71e3a..ef5082d73b6153b49875c61d9b365b873b16145d 100644
|
||||
--- a/lib/internal/main/worker_thread.js
|
||||
+++ b/lib/internal/main/worker_thread.js
|
||||
@@ -27,6 +27,7 @@ const {
|
||||
initializeReport,
|
||||
initializeSourceMapsHandlers,
|
||||
loadPreloadModules,
|
||||
+ setupAsarSupport,
|
||||
setupTraceCategoryState
|
||||
} = require('internal/bootstrap/pre_execution');
|
||||
|
||||
@@ -154,6 +155,8 @@ port.on('message', (message) => {
|
||||
};
|
||||
workerIo.sharedCwdCounter = cwdCounter;
|
||||
|
||||
+ setupAsarSupport();
|
||||
+
|
||||
const CJSLoader = require('internal/modules/cjs/loader');
|
||||
assert(!CJSLoader.hasLoadedAnyUserCJSModule);
|
||||
loadPreloadModules();
|
Loading…
Add table
Add a link
Reference in a new issue