From d9671959336db28dd728b51f50c45f27ff0a8cb7 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Mon, 17 Nov 2025 03:04:28 -0800 Subject: [PATCH] Fix crash in RCTExceptionManager (#54550) Summary: # 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 --- .../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 d49e49a029bcf1..cdaae3aee7f86d 100644 --- a/packages/react-native/React/CoreModules/RCTExceptionsManager.mm +++ b/packages/react-native/React/CoreModules/RCTExceptionsManager.mm @@ -77,8 +77,11 @@ - (void)reportFatal:(NSString *)message 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]); } }