Skip to content

Commit

Permalink
src: Handle bad callback in asyc_wrap
Browse files Browse the repository at this point in the history
Align with the MaybeLocal<> API contract

PR-URL: #31946
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
HarshithaKP authored and gireeshpunathil committed Mar 5, 2020
1 parent cb8898c commit 757e203
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/async_wrap-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@ inline v8::MaybeLocal<v8::Value> AsyncWrap::MakeCallback(
if (!object()->Get(env()->context(), symbol).ToLocal(&cb_v))
return v8::MaybeLocal<v8::Value>();
if (!cb_v->IsFunction()) {
// TODO(addaleax): We should throw an error here to fulfill the
// `MaybeLocal<>` API contract.
return v8::MaybeLocal<v8::Value>();
v8::Isolate* isolate = env()->isolate();
return Undefined(isolate);
}
return MakeCallback(cb_v.As<v8::Function>(), argc, argv);
}
Expand Down

0 comments on commit 757e203

Please sign in to comment.