Skip to content

Commit 03d16f3

Browse files
codebytereJohn Kleinschmidt
authored andcommitted
fix: enable worker threads in ELECTRON_RUN_AS_NODE (electron#20457)
1 parent e501930 commit 03d16f3

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

patches/node/.patches

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,6 @@ chore_read_nobrowserglobals_from_global_not_process.patch
5454
chore_use_v8_inspector_js_protocol_to_find_pdl_file.patch
5555
chore_split_createenvironment_into_createenvironment_and.patch
5656
fix_set_uptime_offset_in_correct_init_method.patch
57+
fix_enable_worker_threads.patch
5758
fsevents-stop-using-fsevents-to-watch-files.patch
5859
fsevents-regression-in-watching.patch
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Shelley Vohr <shelley.vohr@gmail.com>
3+
Date: Thu, 3 Oct 2019 19:03:30 +0200
4+
Subject: fix: enable worker_threads
5+
6+
Electron sets NODE_USE_V8_PLATFORM to false, because Electron
7+
initializes the v8 platform itself and Node.js worker thread
8+
initialization relies on the platform it uses having been set inside
9+
code guarded by NODE_USE_V8_PLATFORM.
10+
11+
This commit fixes this problem by changing node_worker to use the three-arg
12+
implementation of `NewIsolate` to prevent it trying to use a possibly-null ptr.
13+
14+
diff --git a/src/node_worker.cc b/src/node_worker.cc
15+
index 8f97f5c351..2bfbb28e61 100644
16+
--- a/src/node_worker.cc
17+
+++ b/src/node_worker.cc
18+
@@ -112,7 +112,10 @@ class WorkerThreadData {
19+
array_buffer_allocator_(ArrayBufferAllocator::Create()) {
20+
CHECK_EQ(uv_loop_init(&loop_), 0);
21+
22+
- Isolate* isolate = NewIsolate(array_buffer_allocator_.get(), &loop_);
23+
+ Isolate* isolate = NewIsolate(
24+
+ array_buffer_allocator_.get(),
25+
+ &loop_,
26+
+ w->platform_);
27+
CHECK_NOT_NULL(isolate);
28+
29+
{

0 commit comments

Comments
 (0)