File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 77#include " node_buffer.h"
88#include " node_options-inl.h"
99#include " node_perf.h"
10+ #include " node_snapshot_builder.h"
1011#include " util-inl.h"
1112#include " async_wrap-inl.h"
1213
@@ -146,6 +147,20 @@ class WorkerThreadData {
146147 SetIsolateCreateParamsForNode (¶ms);
147148 params.array_buffer_allocator_shared = allocator;
148149
150+ bool use_node_snapshot = true ;
151+ if (w_->per_isolate_opts_ ) {
152+ use_node_snapshot = w_->per_isolate_opts_ ->node_snapshot ;
153+ } else {
154+ // IsolateData is created after the Isolate is created so we'll
155+ // inherit the option from the parent here.
156+ use_node_snapshot = per_process::cli_options->per_isolate ->node_snapshot ;
157+ }
158+ const SnapshotData* snapshot_data =
159+ use_node_snapshot ? SnapshotBuilder::GetEmbeddedSnapshotData ()
160+ : nullptr ;
161+ if (snapshot_data != nullptr ) {
162+ SnapshotBuilder::InitializeIsolateParams (snapshot_data, ¶ms);
163+ }
149164 w->UpdateResourceConstraints (¶ms.constraints );
150165
151166 Isolate* isolate = Isolate::Allocate ();
Original file line number Diff line number Diff line change @@ -10,7 +10,11 @@ if (!process.env.HAS_STARTED_WORKER) {
1010 resourceLimits : {
1111 maxYoungGenerationSizeMb : 0 ,
1212 maxOldGenerationSizeMb : 0
13- }
13+ } ,
14+ // With node snapshot the OOM can occur during the deserialization of
15+ // the context, so disable it since we want the OOM to occur during
16+ // the creation of the message port.
17+ execArgv : [ ...process . execArgv , '--no-node-snapshot' ]
1418 } ;
1519
1620 const worker = new Worker ( __filename , opts ) ;
You can’t perform that action at this time.
0 commit comments