diff --git a/src/async-wrap.cc b/src/async-wrap.cc index 789e357c73..a7a9822238 100644 --- a/src/async-wrap.cc +++ b/src/async-wrap.cc @@ -196,33 +196,28 @@ Local AsyncWrap::MakeCallback(const Local cb, } } - TryCatch try_catch(env()->isolate()); - try_catch.SetVerbose(true); - if (has_domain) { Local enter_v = domain->Get(env()->enter_string()); if (enter_v->IsFunction()) { - enter_v.As()->Call(domain, 0, nullptr); - if (try_catch.HasCaught()) - return Undefined(env()->isolate()); + if (enter_v.As()->Call(domain, 0, nullptr).IsEmpty()) { + FatalError("node::AsyncWrap::MakeCallback", + "domain enter callback threw, please report this"); + } } } if (ran_init_callback() && !pre_fn.IsEmpty()) { - pre_fn->Call(context, 0, nullptr); - if (try_catch.HasCaught()) + if (pre_fn->Call(context, 0, nullptr).IsEmpty()) FatalError("node::AsyncWrap::MakeCallback", "pre hook threw"); } Local ret = cb->Call(context, argc, argv); if (ran_init_callback() && !post_fn.IsEmpty()) { - post_fn->Call(context, 0, nullptr); - if (try_catch.HasCaught()) + if (post_fn->Call(context, 0, nullptr).IsEmpty()) FatalError("node::AsyncWrap::MakeCallback", "post hook threw"); } - // If the return value is empty then the callback threw. if (ret.IsEmpty()) { return Undefined(env()->isolate()); } @@ -230,9 +225,10 @@ Local AsyncWrap::MakeCallback(const Local cb, if (has_domain) { Local exit_v = domain->Get(env()->exit_string()); if (exit_v->IsFunction()) { - exit_v.As()->Call(domain, 0, nullptr); - if (try_catch.HasCaught()) - return Undefined(env()->isolate()); + if (exit_v.As()->Call(domain, 0, nullptr).IsEmpty()) { + FatalError("node::AsyncWrap::MakeCallback", + "domain exit callback threw, please report this"); + } } } @@ -251,9 +247,7 @@ Local AsyncWrap::MakeCallback(const Local cb, return ret; } - env()->tick_callback_function()->Call(process, 0, nullptr); - - if (try_catch.HasCaught()) { + if (env()->tick_callback_function()->Call(process, 0, nullptr).IsEmpty()) { return Undefined(env()->isolate()); } diff --git a/src/env.cc b/src/env.cc index f72ef3445c..5fb4489007 100644 --- a/src/env.cc +++ b/src/env.cc @@ -18,6 +18,7 @@ using v8::Message; using v8::StackFrame; using v8::StackTrace; using v8::TryCatch; +using v8::Value; void Environment::PrintSyncTrace() const { if (!trace_sync_io_) @@ -80,16 +81,10 @@ bool Environment::KickNextTick(Environment::AsyncCallbackScope* scope) { return true; } - // process nextTicks after call - TryCatch try_catch(isolate()); - try_catch.SetVerbose(true); - tick_callback_function()->Call(process_object(), 0, nullptr); + Local ret = + tick_callback_function()->Call(process_object(), 0, nullptr); - if (try_catch.HasCaught()) { - return false; - } - - return true; + return !ret.IsEmpty(); } } // namespace node diff --git a/src/node.cc b/src/node.cc index 99b2968cd6..96485711c0 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1162,33 +1162,28 @@ Local MakeCallback(Environment* env, } } - TryCatch try_catch(env->isolate()); - try_catch.SetVerbose(true); - if (has_domain) { Local enter_v = domain->Get(env->enter_string()); if (enter_v->IsFunction()) { - enter_v.As()->Call(domain, 0, nullptr); - if (try_catch.HasCaught()) - return Undefined(env->isolate()); + if (enter_v.As()->Call(domain, 0, nullptr).IsEmpty()) { + FatalError("node::MakeCallback", + "domain enter callback threw, please report this"); + } } } if (ran_init_callback && !pre_fn.IsEmpty()) { - pre_fn->Call(object, 0, nullptr); - if (try_catch.HasCaught()) + if (pre_fn->Call(object, 0, nullptr).IsEmpty()) FatalError("node::MakeCallback", "pre hook threw"); } Local ret = callback->Call(recv, argc, argv); if (ran_init_callback && !post_fn.IsEmpty()) { - post_fn->Call(object, 0, nullptr); - if (try_catch.HasCaught()) + if (post_fn->Call(object, 0, nullptr).IsEmpty()) FatalError("node::MakeCallback", "post hook threw"); } - // If the return value is empty then the callback threw. if (ret.IsEmpty()) { return Undefined(env->isolate()); } @@ -1196,14 +1191,16 @@ Local MakeCallback(Environment* env, if (has_domain) { Local exit_v = domain->Get(env->exit_string()); if (exit_v->IsFunction()) { - exit_v.As()->Call(domain, 0, nullptr); - if (try_catch.HasCaught()) - return Undefined(env->isolate()); + if (exit_v.As()->Call(domain, 0, nullptr).IsEmpty()) { + FatalError("node::MakeCallback", + "domain exit callback threw, please report this"); + } } } - if (!env->KickNextTick(&callback_scope)) + if (!env->KickNextTick(&callback_scope)) { return Undefined(env->isolate()); + } return ret; }