mirror of
https://github.com/oven-sh/bun
synced 2026-02-15 05:12:29 +00:00
- Add m_hasPendingNapiException flag to track NAPI exception state - Modify napi_throw and throwErrorWithCStrings to check for pending exceptions - Ignore subsequent throws when exception is already pending - Update NAPI preamble to check for pending exceptions - This prevents crashes from multiple ThrowAsJavaScriptException calls 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
22 lines
659 B
JavaScript
22 lines
659 B
JavaScript
import { test, expect } from "bun:test";
|
|
import { join } from "path";
|
|
|
|
const addonPath = join(import.meta.dir, "napi-app", "build", "Debug", "simple_test_addon.node");
|
|
|
|
let addon;
|
|
try {
|
|
addon = require(addonPath);
|
|
console.log("Simple C addon loaded successfully");
|
|
} catch (error) {
|
|
console.warn("Could not load addon:", error.message);
|
|
addon = null;
|
|
}
|
|
|
|
// Test the simple C function that throws two exceptions
|
|
test.skipIf(!addon)("C API double throw test", () => {
|
|
console.log("About to call testDoubleThrow...");
|
|
expect(() => {
|
|
const result = addon.testDoubleThrow();
|
|
console.log("testDoubleThrow returned:", result);
|
|
}).toThrow();
|
|
}); |