@@ -322,6 +322,13 @@ void AsyncWrap::AsyncReset(const FunctionCallbackInfo<Value>& args) {
322322 wrap->AsyncReset (resource, execution_async_id);
323323}
324324
325+ // Useful for debugging async context propagation. Not intended for public use.
326+ void AsyncWrap::GetAsyncContextFrame (const FunctionCallbackInfo<Value>& args) {
327+ AsyncWrap* wrap;
328+ ASSIGN_OR_RETURN_UNWRAP (&wrap, args.This ());
329+
330+ args.GetReturnValue ().Set (wrap->context_frame ());
331+ }
325332
326333void AsyncWrap::GetProviderType (const FunctionCallbackInfo<Value>& args) {
327334 AsyncWrap* wrap;
@@ -372,6 +379,10 @@ Local<FunctionTemplate> AsyncWrap::GetConstructorTemplate(
372379 FIXED_ONE_BYTE_STRING (isolate_data->isolate (), " AsyncWrap" ));
373380 SetProtoMethod (isolate, tmpl, " getAsyncId" , AsyncWrap::GetAsyncId);
374381 SetProtoMethod (isolate, tmpl, " asyncReset" , AsyncWrap::AsyncReset);
382+ SetProtoMethod (isolate,
383+ tmpl,
384+ " getAsyncContextFrameForDebuggingOnly" ,
385+ AsyncWrap::GetAsyncContextFrame);
375386 SetProtoMethod (
376387 isolate, tmpl, " getProviderType" , AsyncWrap::GetProviderType);
377388 isolate_data->set_async_wrap_ctor_template (tmpl);
@@ -501,6 +512,7 @@ void AsyncWrap::RegisterExternalReferences(
501512 registry->Register (RegisterDestroyHook);
502513 registry->Register (AsyncWrap::GetAsyncId);
503514 registry->Register (AsyncWrap::AsyncReset);
515+ registry->Register (AsyncWrap::GetAsyncContextFrame);
504516 registry->Register (AsyncWrap::GetProviderType);
505517}
506518
0 commit comments