From 757bd4152d38a33e489939105af095abe415f507 Mon Sep 17 00:00:00 2001 From: Amir Date: Mon, 17 Aug 2026 04:58:51 +0200 Subject: [PATCH] build: define NODE_API_SWALLOW_UNTHROWABLE_EXCEPTIONS An N-API call that fails with napi_pending_exception while the environment is tearing down currently reaches `throw Error::New(_env)` in Error::ThrowAsJavaScriptException, which has no handler above it in the ThreadSafeFunction dispatch path and terminates the host process. node-addon-api ships a guard for exactly this case, but only behind NODE_API_SWALLOW_UNTHROWABLE_EXCEPTIONS. node-pty depends on node_addon_api_except, whose except.gypi defines NAPI_CPP_EXCEPTIONS and nothing else, so the throwing path is what gets compiled into the prebuilds. Refs #951, #904. --- binding.gyp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/binding.gyp b/binding.gyp index 9e8780ea6..5c6598386 100644 --- a/binding.gyp +++ b/binding.gyp @@ -3,6 +3,15 @@ 'dependencies': [ "