From be8b598661e39a1f81881c269b1285dc60e1129f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Sat, 31 Oct 2026 22:01:02 +0100 Subject: [PATCH] Report Hermes fatal errors on the New Architecture Co-Authored-By: Claude Opus 5.5 (1M context) --- .../runtime/hermes/jni/JHermesInstance.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/runtime/hermes/jni/JHermesInstance.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/runtime/hermes/jni/JHermesInstance.cpp index c9d828ac2fd6..4ac660d40bac 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/runtime/hermes/jni/JHermesInstance.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/runtime/hermes/jni/JHermesInstance.cpp @@ -7,13 +7,31 @@ #include "JHermesInstance.h" +#include #include +#include + +#include namespace facebook::react { +static void hermesFatalHandler(const std::string& reason) { + __android_log_assert(nullptr, "Hermes", "%s", reason.c_str()); +} + +static constinit std::once_flag flag; + jni::local_ref JHermesInstance::initHybrid( jni::alias_ref /* unused */, bool allocInOldGenBeforeTTI) { + std::call_once(flag, []() { + auto* fatalHandlerInterface = + jsi::castInterface( + facebook::hermes::makeHermesRootAPI()); + if (fatalHandlerInterface) { + fatalHandlerInterface->setFatalHandler(hermesFatalHandler); + } + }); return makeCxxInstance(allocInOldGenBeforeTTI); }