Skip to content

Commit d967195

Browse files
cipolleschifacebook-github-bot
authored andcommitted
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
1 parent d52b9d2 commit d967195

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/react-native/React/CoreModules/RCTExceptionsManager.mm

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,11 @@ - (void)reportFatal:(NSString *)message
7777
RCTTriggerReloadCommandListeners(@"JS Crash Reload");
7878
} else if (!RCT_DEV) {
7979
NSString *description = [@"Unhandled JS Exception: " stringByAppendingString:message];
80-
NSDictionary *errorInfo =
81-
@{NSLocalizedDescriptionKey : description, RCTJSStackTraceKey : stack, RCTJSExtraDataKey : extraDataAsJSON};
80+
NSDictionary *errorInfo = @{
81+
NSLocalizedDescriptionKey : description,
82+
RCTJSStackTraceKey : stack == nil ? (id)kCFNull : stack,
83+
RCTJSExtraDataKey : extraDataAsJSON == nil ? (id)kCFNull : extraDataAsJSON
84+
};
8285
RCTFatal([NSError errorWithDomain:RCTErrorDomain code:0 userInfo:errorInfo]);
8386
}
8487
}

0 commit comments

Comments
 (0)