You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Threaded mode: an exception thrown from connect's callback is swallowed — the worker keeps running with the error gone #62
DeliverBatch (src/threaded.mm) calls the connected callback with a raw napi_call_function. It leaves an exception pending, with the comment "Node reports it as that environment's uncaught exception". Under Node's default N-API policy, Node does not do that.
An exception thrown out of a threadsafe function's call_js is reported as a warning and then dropped. On a worker whose parent is parked in runMain, that warning goes to a stderr nobody reads. So the app keeps running with its window up, and the error is gone.
Repro
A worker under runMain whose connect callback throws:
// main threadnative.initApp();newWorker(__filename);process.exit(native.runMain()??0);// workernative.connect((batch)=>{for(constevofbatch)if(ev.type==='window-created')thrownewError('boom');});native.createWindow2({width: 120,height: 80,title: 'probe'});
As is, the process hangs.sample shows the main thread in -[NSApplication run] and the worker idle in uv_run.
With --force-node-api-uncaught-exceptions-policy=true, the process exits 1 with the stack printed.
Measured 2026-09-11 on appkit main at 0b17653, Node 26.0.0, M1 Pro, macOS 15.2.
Proposed
After the call, if napi_is_exception_pending, then napi_get_and_clear_last_exception → napi_fatal_exception(env, err). That makes it the environment's uncaught exception, as the comment says, under either policy.
CALReply, which calls the answer callbacks (pasteboardReadText(cb), measureControl(…, cb) and the rest), is worth checking for the same thing.
react-x11 catches inside its own callback and rethrows from setImmediate in the meantime, so this fix is for every other consumer.
Activity