n-api: Handle fatal exception in async callback
-
Create a handle scope before invoking the async completion callback, because it is basically always needed, easy for user code to forget, and this makes it more consistent with ordinary N-API function callbacks that already have a scope established.
-
Check for an unhandled JS exception after invoking an async completion callback, and report it via
node::FatalException()
. -
Add a corresponding test case for an exception in async callback.
Previously, any unhandled JS exception thrown from a napi_async_complete_callback
would be silently ignored. Among other things this meant assertions in some test cases could be undetected.
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines
Affected core subsystem(s)
n-api