From efd2f679f2cf054bd1301a1e6e851de5cdc38cc7 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Mon, 17 Nov 2025 08:22:19 -0800 Subject: [PATCH] Fix crash in RCTExceptionManager (#54550) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/54550 # Summary This diff resolves a crash in RCTExceptionManager by modifying error handling. It fixes the issue by checking if `RCTJSExtraDataKey` and `RCTJSStackTraceKey` are null or not in a dictionary initializer. Also, `RCTJSExtraDataKey` is marked as nullable but its nullability is not checked. ## Changelog: [iOS][Fixed] - A Crash when some error information are nil Reviewed By: javache Differential Revision: D87140823 fbshipit-source-id: 896d41c5f6559206a6515e402d2a503df6ddb63c --- .../react-native/React/CoreModules/RCTExceptionsManager.mm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/react-native/React/CoreModules/RCTExceptionsManager.mm b/packages/react-native/React/CoreModules/RCTExceptionsManager.mm index d49e49a029b..cdaae3aee7f 100644 --- a/packages/react-native/React/CoreModules/RCTExceptionsManager.mm +++ b/packages/react-native/React/CoreModules/RCTExceptionsManager.mm @@ -77,8 +77,11 @@ RCT_EXPORT_MODULE() RCTTriggerReloadCommandListeners(@"JS Crash Reload"); } else if (!RCT_DEV) { NSString *description = [@"Unhandled JS Exception: " stringByAppendingString:message]; - NSDictionary *errorInfo = - @{NSLocalizedDescriptionKey : description, RCTJSStackTraceKey : stack, RCTJSExtraDataKey : extraDataAsJSON}; + NSDictionary *errorInfo = @{ + NSLocalizedDescriptionKey : description, + RCTJSStackTraceKey : stack == nil ? (id)kCFNull : stack, + RCTJSExtraDataKey : extraDataAsJSON == nil ? (id)kCFNull : extraDataAsJSON + }; RCTFatal([NSError errorWithDomain:RCTErrorDomain code:0 userInfo:errorInfo]); } }