node-report
node-report copied to clipboard
errors caught from n-api addons shouldn't trigger UncaughtException reports
WIP.
Refs: https://github.com/nodejs/node-report/issues/131
Added test. Need to look at how to fix.
I think I'm going to need some help here. I've added two tests to this PR, one based on n-api and the other using nan which I think should replicate https://github.com/nodejs/node-report/issues/131. However the nan version is passing while the n-api version is not. I expected both tests to fail.
Could someone:
- Verify that the two tests (the nan and n-api versions) are equivalent?
- Explain the difference in behaviour (i.e. why the n-api version results in an UncaughtException but the nan version does not)?
cc @nodejs/addon-api @nodejs/n-api @mmarchini
Verify that the two tests (the nan and n-api versions) are equivalent?
They look equivalent to me. Ultimately they both end up calling v8::Isolate::ThrowException()
.
Thanks Ben. So the question remains over the behavioral differences and whether this is an n-api issue (since it doesn't happen with the nan based equivalent)?
N-API seems to create a v8::TryCatch
object before throwing (as part of the NAPI_PREAMBLE
). It might be related, depending on how V8's catch-prediction handles C++ TryCatch blocks (although I couldn't replicate the same behavior in nan
, even after wrapping ThrowError
with a v8::TryCatch
object).