diff options
author | Stephen Belanger <admin@stephenbelanger.com> | 2020-12-04 21:24:05 +0300 |
---|---|---|
committer | Stephen Belanger <stephen.belanger@datadoghq.com> | 2021-05-07 01:17:49 +0300 |
commit | f37c26b8a2e10d0a53a60a2fad5b0133ad33308a (patch) | |
tree | bdc0979853e3f5233609607d8df7a8a9f1c99201 /src | |
parent | c8e4020a212cd1ce6692d069eb39d59f40424aa5 (diff) |
async_hooks: use new v8::Context PromiseHook API
PR-URL: https://github.com/nodejs/node/pull/36394
Reviewed-By: Bryan English <bryan@bryanenglish.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/async_wrap.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/async_wrap.cc b/src/async_wrap.cc index 0baf8010907..a1c76b94138 100644 --- a/src/async_wrap.cc +++ b/src/async_wrap.cc @@ -452,6 +452,15 @@ static void EnablePromiseHook(const FunctionCallbackInfo<Value>& args) { } } +static void SetPromiseHooks(const FunctionCallbackInfo<Value>& args) { + Environment* env = Environment::GetCurrent(args); + Local<Context> ctx = env->context(); + ctx->SetPromiseHooks( + args[0]->IsFunction() ? args[0].As<Function>() : Local<Function>(), + args[1]->IsFunction() ? args[1].As<Function>() : Local<Function>(), + args[2]->IsFunction() ? args[2].As<Function>() : Local<Function>(), + args[3]->IsFunction() ? args[3].As<Function>() : Local<Function>()); +} static void DisablePromiseHook(const FunctionCallbackInfo<Value>& args) { Environment* env = Environment::GetCurrent(args); @@ -631,6 +640,7 @@ void AsyncWrap::Initialize(Local<Object> target, env->SetMethod(target, "clearAsyncIdStack", ClearAsyncIdStack); env->SetMethod(target, "queueDestroyAsyncId", QueueDestroyAsyncId); env->SetMethod(target, "enablePromiseHook", EnablePromiseHook); + env->SetMethod(target, "setPromiseHooks", SetPromiseHooks); env->SetMethod(target, "disablePromiseHook", DisablePromiseHook); env->SetMethod(target, "registerDestroyHook", RegisterDestroyHook); @@ -725,6 +735,7 @@ void AsyncWrap::RegisterExternalReferences( registry->Register(ClearAsyncIdStack); registry->Register(QueueDestroyAsyncId); registry->Register(EnablePromiseHook); + registry->Register(SetPromiseHooks); registry->Register(DisablePromiseHook); registry->Register(RegisterDestroyHook); registry->Register(AsyncWrap::GetAsyncId); |