diff options
Diffstat (limited to 'src/api')
-rw-r--r-- | src/api/callback.cc | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/api/callback.cc b/src/api/callback.cc index 6d4e28e1d9..bced9bb7ab 100644 --- a/src/api/callback.cc +++ b/src/api/callback.cc @@ -43,12 +43,13 @@ InternalCallbackScope::InternalCallbackScope(AsyncWrap* async_wrap) InternalCallbackScope::InternalCallbackScope(Environment* env, Local<Object> object, const async_context& asyncContext, - ResourceExpectation expect) + int flags) : env_(env), async_context_(asyncContext), object_(object), - callback_scope_(env) { - CHECK_IMPLIES(expect == kRequireResource, !object.IsEmpty()); + callback_scope_(env), + skip_hooks_(flags & kSkipAsyncHooks) { + CHECK_IMPLIES(!(flags & kAllowEmptyResource), !object.IsEmpty()); CHECK_NOT_NULL(env); if (!env->can_call_into_js()) { @@ -60,7 +61,7 @@ InternalCallbackScope::InternalCallbackScope(Environment* env, // If you hit this assertion, you forgot to enter the v8::Context first. CHECK_EQ(Environment::GetCurrent(env->isolate()), env); - if (asyncContext.async_id != 0) { + if (asyncContext.async_id != 0 && !skip_hooks_) { // No need to check a return value because the application will exit if // an exception occurs. AsyncWrap::EmitBefore(env, asyncContext.async_id); @@ -89,7 +90,7 @@ void InternalCallbackScope::Close() { if (failed_) return; - if (async_context_.async_id != 0) { + if (async_context_.async_id != 0 && !skip_hooks_) { AsyncWrap::EmitAfter(env_, async_context_.async_id); } |