@@ -120,16 +120,26 @@ static void DisableHooksJS(const FunctionCallbackInfo<Value>& args) {
120120
121121static void GetCurrentAsyncId (const FunctionCallbackInfo<Value>& args) {
122122 Environment* env = Environment::GetCurrent (args);
123- v8::Local<v8::Value> uid = v8::Integer::New (env->isolate (), env->get_current_async_wrap_uid ());
123+ v8::Local<v8::Value> uid = v8::Integer::New (env->isolate (), env->async_hooks ()-> get_current_async_wrap_uid ());
124124 args.GetReturnValue ().Set (uid);
125125}
126126
127127static void GetNextAsyncId (const FunctionCallbackInfo<Value>& args) {
128128 Environment* env = Environment::GetCurrent (args);
129- v8::Local<v8::Integer> uid = v8::Integer::New (env->isolate (), env->get_next_async_wrap_uid ());
129+ v8::Local<v8::Integer> uid = v8::Integer::New (env->isolate (), env->async_hooks ()-> get_next_async_wrap_uid ());
130130 args.GetReturnValue ().Set (uid);
131131}
132132
133+ static void GetCurrentAsyncId2 (const FunctionCallbackInfo<Value>& args) {
134+ Environment* env = Environment::GetCurrent (args);
135+ args.GetReturnValue ().Set (env->async_hooks ()->get_current_async_id_array ());
136+ }
137+
138+ static void GetNextAsyncId2 (const FunctionCallbackInfo<Value>& args) {
139+ Environment* env = Environment::GetCurrent (args);
140+ args.GetReturnValue ().Set (env->async_hooks ()->get_next_async_id_array ());
141+ }
142+
133143static bool FireAsyncInitCallbacksInternal (
134144 Environment* env,
135145 int64_t uid,
@@ -243,7 +253,7 @@ void AsyncWrap::FireAsyncPreCallbacks(
243253 v8::Local<v8::Number> uid,
244254 v8::Local<v8::Object> obj)
245255{
246- env->set_current_async_wrap_uid (uid->IntegerValue ());
256+ env->async_hooks ()-> set_current_async_wrap_uid (uid->IntegerValue ());
247257
248258 if (ranInitCallbacks) {
249259 Local<Function> pre_fn = env->async_hooks_pre_function ();
@@ -283,7 +293,7 @@ void AsyncWrap::FireAsyncPostCallbacks(Environment* env, bool ranInitCallback, v
283293 }
284294 }
285295
286- env->set_current_async_wrap_uid (0 );
296+ env->async_hooks ()-> set_current_async_wrap_uid (0 );
287297}
288298
289299static void NotifyAsyncEndFromJS (const FunctionCallbackInfo<Value>& args) {
@@ -351,10 +361,9 @@ static void SetupHooks(const FunctionCallbackInfo<Value>& args) {
351361 env->set_async_hooks_destroy_function (destroy_v.As <Function>());
352362}
353363
354-
355364static void Initialize (Local<Object> target,
356- Local<Value> unused,
357- Local<Context> context) {
365+ Local<Value> unused,
366+ Local<Context> context) {
358367 Environment* env = Environment::GetCurrent (context);
359368 Isolate* isolate = env->isolate ();
360369 HandleScope scope (isolate);
@@ -364,6 +373,8 @@ static void Initialize(Local<Object> target,
364373 env->SetMethod (target, " enable" , EnableHooksJS);
365374 env->SetMethod (target, " getCurrentAsyncId" , GetCurrentAsyncId);
366375 env->SetMethod (target, " getNextAsyncId" , GetNextAsyncId);
376+ env->SetMethod (target, " getCurrentAsyncId2" , GetCurrentAsyncId2);
377+ env->SetMethod (target, " getNextAsyncId2" , GetNextAsyncId2);
367378 env->SetMethod (target, " notifyAsyncEnqueue" , NotifyAsyncEnqueueFromJS);
368379 env->SetMethod (target, " notifyAsyncStart" , NotifyAsyncStartFromJS);
369380 env->SetMethod (target, " notifyAsyncEnd" , NotifyAsyncEndFromJS);
0 commit comments