Fix assertion when modules are accessed early on in bridge startup
This commit is contained in:
parent
9ffbfaeb35
commit
7bf157c92c
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue