Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tried to access a JS module before the React instance was fully set up #877

Closed
abdullahizzuddiin opened this issue Oct 8, 2019 · 7 comments · May be fixed by #906
Closed

Tried to access a JS module before the React instance was fully set up #877

abdullahizzuddiin opened this issue Oct 8, 2019 · 7 comments · May be fixed by #906

Comments

@abdullahizzuddiin
Copy link

Description:

Caused by java.lang.RuntimeException
Tried to access a JS module before the React instance was fully set up. Calls to ReactContext#getJSModule should only happen once initialize() has been called on your native module.

Environment
Version: 3.3.0
Install using: yarn

Steps to Reproduce Issue:
Actually, I cannot reproduce this issue. But, thousand users of my app get this error
Screenshot from 2019-10-08 10-54-41

Anything else:

Caused by java.lang.RuntimeException: Tried to access a JS module before the React instance was fully set up. Calls to ReactContext#getJSModule should only happen once initialize() has been called on your native module.
       at com.facebook.react.bridge.ReactContext.getJSModule(ReactContext.java:107)
       at com.geektime.rnonesignalandroid.RNOneSignal.sendEvent(RNOneSignal.java:102)
       at com.geektime.rnonesignalandroid.RNOneSignal.notificationReceived(RNOneSignal.java:413)
       at com.onesignal.OneSignal.handleNotificationReceived(OneSignal.java:2025)
       at com.onesignal.NotificationExtenderService.processJsonObject(NotificationExtenderService.java:194)
     (crash stacktraces, as well as any other information here)  at com.onesignal.NotificationExtenderService.processIntent(NotificationExtenderService.java:155)
       at com.onesignal.NotificationExtenderService.onHandleWork(NotificationExtenderService.java:123)
       at com.onesignal.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:439)
       at com.onesignal.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:430)
       at android.os.AsyncTask$2.call(AsyncTask.java:295)
       at java.util.concurrent.FutureTask.run(FutureTask.java:237)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at java.lang.Thread.run(Thread.java:818)
@rgomezp
Copy link
Contributor

rgomezp commented Oct 9, 2019

Howdy,
Unfortunately, it's hard to know what may be happening or how to fix this if we don't have repro steps. If anyone has any further details, it would be very helpful.

@rgomezp
Copy link
Contributor

rgomezp commented Oct 29, 2019

Closing due to no response

@rgomezp rgomezp closed this as completed Oct 29, 2019
@moxspoy
Copy link

moxspoy commented Nov 29, 2019

Hallo, im facing same issue. The issue was founded in Crashlytics, so we cannot reproduce this kind of bug.

@abdullahizzuddiin
Copy link
Author

Hello, @moxspoy . Do yo know how to reproduce those errors?

According to my firebase console, those errors always occurred when the application in the beginning.

image

@panncr
Copy link

panncr commented Nov 29, 2019

Maybe, notification received when the app still start up?

Have you tried to sent notification specific for your device a moment after you open the app?

@abdullahizzuddiin
Copy link
Author

Yes @panncr . Your statement is true. After I followed your advice, I sent notification to my device exact after I open the app, my app is force closed.

I solved this issue by updated sendEvent() method on node_modules/react-native-onesignal/android/src/main/java/com/geektime/rnonesignalandroid/RNOneSignal.java

private void sendEvent(String eventName, Object params) {
        if(!mReactContext.hasActiveCatalystInstance()) {
            return;
        }

        mReactContext
              .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
              .emit(eventName, params);
    }

@rgomezp
Copy link
Contributor

rgomezp commented Nov 11, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants