Files
bun.sh/test/napi/simple-double-throw.test.js
Claude Bot 6bcfa2fd1e Fix NAPI multiple exception handling to match Node.js behavior
- 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>
2025-08-11 13:52:45 +00:00

22 lines
637 B
JavaScript

import { test, expect } from "bun:test";
import { join } from "path";
const addonPath = join(import.meta.dir, "napi-app", "build", "Debug", "multiple_exceptions_addon.node");
let addon;
try {
addon = require(addonPath);
console.log("Addon loaded successfully");
} catch (error) {
console.warn("Could not load addon:", error.message);
addon = null;
}
// Test just one simple function at a time
test.skipIf(!addon)("simple exception test", () => {
console.log("About to call throwMultiple...");
expect(() => {
const result = addon.throwMultiple();
console.log("throwMultiple returned:", result);
}).toThrow();
});