From 85bdd75828f85230aaa90ed510666457c46f996c Mon Sep 17 00:00:00 2001 From: Maddie Lord Date: Fri, 27 Dec 2024 16:59:49 -0800 Subject: [PATCH] Add "jsEngine: hermes" to JS runtime Error prototype (#48401) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48401 This change adds a flag to JS Error's prototype to specify the jsEngine. Reviewed By: fkgozali Differential Revision: D67665484 fbshipit-source-id: 64b7b4bd986bcbd45d58e70c1a16de6752b05ccd --- .../ReactCommon/react/runtime/hermes/HermesInstance.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/react-native/ReactCommon/react/runtime/hermes/HermesInstance.cpp b/packages/react-native/ReactCommon/react/runtime/hermes/HermesInstance.cpp index d12832d1cba400..f3a215c622089a 100644 --- a/packages/react-native/ReactCommon/react/runtime/hermes/HermesInstance.cpp +++ b/packages/react-native/ReactCommon/react/runtime/hermes/HermesInstance.cpp @@ -153,6 +153,11 @@ std::unique_ptr HermesInstance::createJSRuntime( std::unique_ptr hermesRuntime = hermes::makeHermesRuntime(runtimeConfigBuilder.build()); + auto errorPrototype = hermesRuntime->global() + .getPropertyAsObject(*hermesRuntime, "Error") + .getPropertyAsObject(*hermesRuntime, "prototype"); + errorPrototype.setProperty(*hermesRuntime, "jsEngine", "hermes"); + #ifdef HERMES_ENABLE_DEBUGGER auto& inspectorFlags = jsinspector_modern::InspectorFlags::getInstance(); if (!inspectorFlags.getFuseboxEnabled()) {