-
Notifications
You must be signed in to change notification settings - Fork 462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
src: handle failure during error wrap of primitive #1310
src: handle failure during error wrap of primitive #1310
Conversation
When we wrap a primitive value into an object in order to throw it as an error, we call `napi_define_properties()` which may return `napi_pending_exception` if the environment is shutting down. Handle this case when `NODE_API_SWALLOW_UNTHROWABLE_EXCEPTIONS` is given by checking whether we're in an environment shutdown scenario and ignore the failure of `napi_define_properties()`, since the error will not reach JS anyway.
Note that this change will become mostly dead code because we're only down this path if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
When we wrap a primitive value into an object in order to throw it as an error, we call `napi_define_properties()` which may return `napi_pending_exception` if the environment is shutting down. Handle this case when `NODE_API_SWALLOW_UNTHROWABLE_EXCEPTIONS` is given by checking whether we're in an environment shutdown scenario and ignore the failure of `napi_define_properties()`, since the error will not reach JS anyway. Signed-off-by: Gabriel Schulhof <gabrielschulhof@gmail.com> PR-URL: #1310 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
Landed in 64f6515. |
When we wrap a primitive value into an object in order to throw it as an error, we call `napi_define_properties()` which may return `napi_pending_exception` if the environment is shutting down. Handle this case when `NODE_API_SWALLOW_UNTHROWABLE_EXCEPTIONS` is given by checking whether we're in an environment shutdown scenario and ignore the failure of `napi_define_properties()`, since the error will not reach JS anyway. Signed-off-by: Gabriel Schulhof <gabrielschulhof@gmail.com> PR-URL: nodejs/node-addon-api#1310 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
When we wrap a primitive value into an object in order to throw it as an error, we call
napi_define_properties()
which may returnnapi_pending_exception
if the environment is shutting down. Handle this case whenNODE_API_SWALLOW_UNTHROWABLE_EXCEPTIONS
is given by checking whether we're in an environment shutdown scenario and ignore the failure ofnapi_define_properties()
, since the error will not reach JS anyway.