Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 98c8f76

Browse filesBrowse files
codebyteretargos
authored andcommitted
src: split up InitializeContext
This splits out code from InitializeContext into a new function InitializeContextForSnapshot and moves the callsite of InitializeContextRuntime from NewContext to InitializeContext - embedders don't necessarily call NewContext and so need to be able to guarantee these functions are called regardless. PR-URL: #30067 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 87f14e1 commit 98c8f76
Copy full SHA for 98c8f76

File tree

Expand file treeCollapse file tree

1 file changed

+13
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-3
lines changed
Open diff view settings
Collapse file

‎src/api/environment.cc‎

Copy file name to clipboardExpand all lines: src/api/environment.cc
+13-3Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,9 @@ MaybeLocal<Object> GetPerContextExports(Local<Context> context) {
361361
return handle_scope.Escape(exports);
362362
}
363363

364+
// Any initialization logic should be performed in
365+
// InitializeContext, because embedders don't necessarily
366+
// call NewContext and so they will experience breakages.
364367
Local<Context> NewContext(Isolate* isolate,
365368
Local<ObjectTemplate> object_template) {
366369
auto context = Context::New(isolate, nullptr, object_template);
@@ -370,8 +373,6 @@ Local<Context> NewContext(Isolate* isolate,
370373
return Local<Context>();
371374
}
372375

373-
InitializeContextRuntime(context);
374-
375376
return context;
376377
}
377378

@@ -405,7 +406,7 @@ void InitializeContextRuntime(Local<Context> context) {
405406
}
406407
}
407408

408-
bool InitializeContext(Local<Context> context) {
409+
bool InitializeContextForSnapshot(Local<Context> context) {
409410
Isolate* isolate = context->GetIsolate();
410411
HandleScope handle_scope(isolate);
411412

@@ -459,6 +460,15 @@ bool InitializeContext(Local<Context> context) {
459460
return true;
460461
}
461462

463+
bool InitializeContext(Local<Context> context) {
464+
if (!InitializeContextForSnapshot(context)) {
465+
return false;
466+
}
467+
468+
InitializeContextRuntime(context);
469+
return true;
470+
}
471+
462472
uv_loop_t* GetCurrentEventLoop(Isolate* isolate) {
463473
HandleScope handle_scope(isolate);
464474
Local<Context> context = isolate->GetCurrentContext();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.