From 9b4bb54fdff89cb9d7f41c17a720aa58d913f652 Mon Sep 17 00:00:00 2001 From: Phillip Pan Date: Wed, 16 Mar 2022 21:03:36 -0700 Subject: [PATCH] add error logs for nil moduleRegistry Summary: Changelog: [Internal] for the last 6 months or so, we've been getting this task where the moduleRegistry in RCTDeviceInfo is nil. in this change, i add some logs to see what might be setting this to nil. in all honestly, i don't really think this is happening, but it would be good to verify. Reviewed By: sshic Differential Revision: D34908902 fbshipit-source-id: d375285467a87453605ba0fecfc124bc3bff6e63 --- React/CoreModules/RCTDeviceInfo.mm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/React/CoreModules/RCTDeviceInfo.mm b/React/CoreModules/RCTDeviceInfo.mm index b948e8e479b..c5bc2cdb728 100644 --- a/React/CoreModules/RCTDeviceInfo.mm +++ b/React/CoreModules/RCTDeviceInfo.mm @@ -69,6 +69,14 @@ RCT_EXPORT_MODULE() object:nil]; } +- (void)setModuleRegistry:(RCTModuleRegistry *)moduleRegistry +{ + if (!moduleRegistry) { + RCTAssert(false, @"moduleRegistry should not be nil, _moduleRegistry is nil: %d", _moduleRegistry == nil); + } + _moduleRegistry = moduleRegistry; +} + static BOOL RCTIsIPhoneX() { static BOOL isIPhoneX = NO;