11#include " node.h"
2- #include " v8.h"
32#include " uv.h"
3+ #include " v8.h"
44
55#include < assert.h>
6- #include < vector>
76#include < memory>
7+ #include < vector>
88
99namespace {
1010
1111void RunInCallbackScope (const v8::FunctionCallbackInfo<v8::Value>& args) {
1212 v8::Isolate* isolate = args.GetIsolate ();
13+ v8::Local<v8::Context> context = isolate->GetCurrentContext ();
14+ node::Environment* env = node::GetCurrentEnvironment (context);
1315
1416 assert (args.Length () == 4 );
1517 assert (args[0 ]->IsObject ());
@@ -22,11 +24,11 @@ void RunInCallbackScope(const v8::FunctionCallbackInfo<v8::Value>& args) {
2224 args[2 ].As <v8::Number>()->Value ()
2325 };
2426
25- node::CallbackScope scope (isolate , args[0 ].As <v8::Object>(), asyncContext);
27+ node::CallbackScope scope (env , args[0 ].As <v8::Object>(), asyncContext);
2628 v8::Local<v8::Function> fn = args[3 ].As <v8::Function>();
2729
2830 v8::MaybeLocal<v8::Value> ret =
29- fn->Call (isolate-> GetCurrentContext () , args[0 ], 0 , nullptr );
31+ fn->Call (context , args[0 ], 0 , nullptr );
3032
3133 if (!ret.IsEmpty ())
3234 args.GetReturnValue ().Set (ret.ToLocalChecked ());
@@ -35,12 +37,14 @@ void RunInCallbackScope(const v8::FunctionCallbackInfo<v8::Value>& args) {
3537static void Callback (uv_work_t * req, int ignored) {
3638 v8::Isolate* isolate = v8::Isolate::GetCurrent ();
3739 v8::HandleScope scope (isolate);
38- node::CallbackScope callback_scope (isolate, v8::Object::New (isolate),
40+ v8::Local<v8::Context> context = isolate->GetCurrentContext ();
41+ node::Environment* env = node::GetCurrentEnvironment (context);
42+ node::CallbackScope callback_scope (env, v8::Object::New (isolate),
3943 node::async_context{0 , 0 });
4044 std::unique_ptr<v8::Global<v8::Promise::Resolver>> persistent {
4145 static_cast <v8::Global<v8::Promise::Resolver>*>(req->data ) };
4246 v8::Local<v8::Promise::Resolver> local = persistent->Get (isolate);
43- local->Resolve (isolate-> GetCurrentContext () ,
47+ local->Resolve (context ,
4448 v8::Undefined (isolate)).ToChecked ();
4549 delete req;
4650}
0 commit comments