mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fail silently in AppStateModule.sendEvent if CatalystInstance is not available
Summary: According to our logs, 80% of these warnings are coming from AppStateModule. It's not particularly interesting or surprising that the CatalystInstance would be torn down when there's some app event, so let's stop taking up DB space with a useless message. Reviewed By: ejanzer, mdvacca Differential Revision: D20879426 fbshipit-source-id: b1182461aed4a66d82cb34bbd4b12782af6ed7b3
This commit is contained in:
committed by
Facebook GitHub Bot
parent
a37e45a57e
commit
c4806fada6
@@ -92,11 +92,18 @@ public class AppStateModule extends NativeAppStateSpec
|
||||
}
|
||||
|
||||
private void sendEvent(String eventName, @Nullable Object data) {
|
||||
ReactApplicationContext reactApplicationContext = getReactApplicationContextIfActiveOrWarn();
|
||||
ReactApplicationContext reactApplicationContext = getReactApplicationContext();
|
||||
|
||||
if (reactApplicationContext != null) {
|
||||
reactApplicationContext.getJSModule(RCTDeviceEventEmitter.class).emit(eventName, data);
|
||||
if (reactApplicationContext == null) {
|
||||
return;
|
||||
}
|
||||
// We don't gain anything interesting from logging here, and it's an extremely common
|
||||
// race condition for an AppState event to be triggered as the Catalyst instance is being
|
||||
// set up or torn down. So, just fail silently here.
|
||||
if (!reactApplicationContext.hasActiveCatalystInstance()) {
|
||||
return;
|
||||
}
|
||||
reactApplicationContext.getJSModule(RCTDeviceEventEmitter.class).emit(eventName, data);
|
||||
}
|
||||
|
||||
private void sendAppStateChangeEvent() {
|
||||
|
||||
Reference in New Issue
Block a user