From ea9c3ffaa240fc968832871000832eda1b92934a Mon Sep 17 00:00:00 2001 From: snek Date: Wed, 16 Oct 2024 12:30:19 +0200 Subject: fix: node-api function call should use preamble (#26297) `napi_call_function` should use our equiv of NAPI_PREAMBLE (`&mut Env` instead of `*mut Env`) since it needs to set error codes based on whether the body of the function raised a JS exception. Fixes: https://github.com/denoland/deno/issues/26282 --- tests/napi/callback_test.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tests/napi/callback_test.js') diff --git a/tests/napi/callback_test.js b/tests/napi/callback_test.js index 98622d48d..c132fefa1 100644 --- a/tests/napi/callback_test.js +++ b/tests/napi/callback_test.js @@ -1,6 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -import { assertEquals, loadTestLibrary } from "./common.js"; +import { assertEquals, assertThrows, loadTestLibrary } from "./common.js"; const callback = loadTestLibrary(); @@ -36,3 +36,12 @@ Deno.test("napi callback run with args & recv", function () { ); assertEquals(result, 69); }); + +Deno.test("napi callback handles errors correctly", function () { + const e = new Error("hi!"); + assertThrows(() => { + callback.test_callback_throws(() => { + throw e; + }); + }, e); +}); -- cgit v1.2.3