node-report icon indicating copy to clipboard operation
node-report copied to clipboard

errors caught from n-api addons shouldn't trigger UncaughtException reports

Open richardlau opened this issue 5 years ago • 4 comments

WIP.

Refs: https://github.com/nodejs/node-report/issues/131

Added test. Need to look at how to fix.

richardlau avatar Jun 26 '19 16:06 richardlau

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:

  1. Verify that the two tests (the nan and n-api versions) are equivalent?
  2. 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

richardlau avatar Jun 26 '19 18:06 richardlau

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().

bnoordhuis avatar Jun 26 '19 18:06 bnoordhuis

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)?

richardlau avatar Jun 26 '19 18:06 richardlau

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).

mmarchini avatar Jun 28 '19 00:06 mmarchini