GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: split up InitializeContext · cheza24/node@b086e38

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src/api
    • environment.cc
Expand file treeCollapse file tree
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)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.