diff --git a/src/async_wrap.cc b/src/async_wrap.cc index 0c84b06fdde346..8a487a9dd31f94 100644 --- a/src/async_wrap.cc +++ b/src/async_wrap.cc @@ -294,12 +294,15 @@ static void SetupHooks(const FunctionCallbackInfo& args) { Local fn_obj = args[0].As(); -#define SET_HOOK_FN(name) \ - Local name##_v = fn_obj->Get( \ - env->context(), \ - FIXED_ONE_BYTE_STRING(env->isolate(), #name)).ToLocalChecked(); \ - CHECK(name##_v->IsFunction()); \ - env->set_async_hooks_##name##_function(name##_v.As()); +#define SET_HOOK_FN(name) \ + do { \ + Local v = \ + fn_obj->Get(env->context(), \ + FIXED_ONE_BYTE_STRING(env->isolate(), #name)) \ + .ToLocalChecked(); \ + CHECK(v->IsFunction()); \ + env->set_async_hooks_##name##_function(v.As()); \ + } while (0) SET_HOOK_FN(init); SET_HOOK_FN(before); @@ -502,7 +505,7 @@ void AsyncWrap::Initialize(Local target, Local constants = Object::New(isolate); #define SET_HOOKS_CONSTANT(name) \ FORCE_SET_TARGET_FIELD( \ - constants, #name, Integer::New(isolate, AsyncHooks::name)); + constants, #name, Integer::New(isolate, AsyncHooks::name)) SET_HOOKS_CONSTANT(kInit); SET_HOOKS_CONSTANT(kBefore);