diff --git a/atom/common/native_mate_converters/callback.h b/atom/common/native_mate_converters/callback.h index 6e51cda79c49..68ea911fe143 100644 --- a/atom/common/native_mate_converters/callback.h +++ b/atom/common/native_mate_converters/callback.h @@ -70,10 +70,13 @@ struct V8FunctionInvoker { v8::Local holder = function->NewHandle(); v8::Local context = holder->CreationContext(); v8::Context::Scope context_scope(context); - ReturnType ret; + ReturnType ret = ReturnType(); std::vector> args = { ConvertToV8(isolate, raw)... }; - v8::Local val(holder->Call(holder, args.size(), &args.front())); - Converter::FromV8(isolate, val, &ret); + v8::Local result; + auto maybe_result = + holder->Call(context, holder, args.size(), &args.front()); + if (maybe_result.ToLocal(&result)) + Converter::FromV8(isolate, result, &ret); return ret; } };