deno
7607cb20 - fix(ext/napi): prevent spurious TypeError from napi_coerce_to_object on null/undefined (#32695)

Commit
182 days ago
fix(ext/napi): prevent spurious TypeError from napi_coerce_to_object on null/undefined (#32695) Fixes #31306 Fixes #28682 - `napi_coerce_to_object(null/undefined)` was letting V8's `ToObject()` throw a TypeError, which got stored in `env.last_exception` by the `napi_wrap!` try-catch, then re-thrown by `call_fn` as a spurious unhandled rejection - This masked real errors in NAPI modules like rolldown — plugin errors showed "Cannot convert undefined or null to object" instead of the actual error message - Fix: check for null/undefined before calling `to_object()`, returning `napi_invalid_arg` without generating a V8 exception - Added regression test that verifies `napi_coerce_to_object(null/undefined)` returns an error status without leaving a pending exception --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Author
Parents
Loading