From 808379c379d7f295e9e6c58582cdadc349699cb5 Mon Sep 17 00:00:00 2001 From: Harshitha KP Date: Tue, 25 Feb 2020 02:46:16 -0500 Subject: [PATCH] src: Handle bad callback in asyc_wrap Align with the MaybeLocal<> API contract PR-URL: https://github.com/nodejs/node/pull/31946 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- src/async_wrap-inl.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/async_wrap-inl.h b/src/async_wrap-inl.h index e3e48666e4fbd6..03745081f3b09b 100644 --- a/src/async_wrap-inl.h +++ b/src/async_wrap-inl.h @@ -74,9 +74,8 @@ inline v8::MaybeLocal AsyncWrap::MakeCallback( if (!object()->Get(env()->context(), symbol).ToLocal(&cb_v)) return v8::MaybeLocal(); if (!cb_v->IsFunction()) { - // TODO(addaleax): We should throw an error here to fulfill the - // `MaybeLocal<>` API contract. - return v8::MaybeLocal(); + v8::Isolate* isolate = env()->isolate(); + return Undefined(isolate); } return MakeCallback(cb_v.As(), argc, argv); }