Skip to content
Browse files
Fail silently in AppStateModule.sendEvent if CatalystInstance is not …

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
  • Loading branch information
JoshuaGross authored and facebook-github-bot committed Apr 7, 2020
1 parent a37e45a commit c4806fada6532894e2242cf31f7145d2992e3a2b
Showing 1 changed file with 10 additions and 3 deletions.
@@ -92,11 +92,18 @@ private WritableMap createAppStateEventMap() {

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) {
// 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()) {
reactApplicationContext.getJSModule(RCTDeviceEventEmitter.class).emit(eventName, data);

private void sendAppStateChangeEvent() {

0 comments on commit c4806fa

Please sign in to comment.