diff --git a/React/Base/RCTBatchedBridge.m b/React/Base/RCTBatchedBridge.m index ad0cc39eef2..5ef4c65026e 100644 --- a/React/Base/RCTBatchedBridge.m +++ b/React/Base/RCTBatchedBridge.m @@ -407,9 +407,10 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR - (NSDictionary *)modules { - RCTAssert(!self.isValid || _modulesByName != nil, @"Bridge modules have not yet been initialized. " - "You may be trying to access a module too early in the startup procedure."); - + if (RCT_DEBUG && self.isValid && _modulesByName == nil) { + RCTLogError(@"Bridge modules have not yet been initialized. You may be " + "trying to access a module too early in the startup procedure."); + } return _modulesByName; } diff --git a/React/Base/RCTLog.m b/React/Base/RCTLog.m index a8679da9e04..ebbf6a1b85b 100644 --- a/React/Base/RCTLog.m +++ b/React/Base/RCTLog.m @@ -226,7 +226,11 @@ void _RCTLogFormat( } } }]; - [[RCTBridge currentBridge].redBox showErrorMessage:message withStack:stack]; + dispatch_async(dispatch_get_main_queue(), ^{ + // red box is thread safe, but by deferring to main queue we avoid a startup + // race condition that causes the module to be accessed before it has loaded + [[RCTBridge currentBridge].redBox showErrorMessage:message withStack:stack]; + }); } // Log to JS executor