realm / realm-js

Realm is a mobile database: an alternative to SQLite & key-value stores
https://realm.io
Apache License 2.0
5.62k stars 558 forks source link

"Module AppRegistry is not a registered callable module" with remote debugging #562

Closed paldepind closed 3 years ago

paldepind commented 7 years ago

When I include Realm in my project and use remote JS debugging I see the following error on the phone: "Module AppRegistry is not a registered callable module". And the Chrome log shows:

POST http://10.8.239.5:8082/create_session net::ERR_CONNECTION_REFUSED
10.141.19.252:8082/create_session:1 POST http://10.141.19.252:8082/create_session net::ERR_CONNECTION_REFUSED
DOMException: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'http://10.141.19.252:8082/create_session'.(…)
Realm failed to connect to the embedded debug server inside the app. If attempting to use Chrome debugging from a device, ensure the device is reachable on the same network as this machine.
Module AppRegistry is not a registered callable module.

It seems odd that the errors mention port 8082 since my local dev server is running on port 8082.

This is likely related to #465. The last comment in that thread mentions that remote debugging may not work at all. If that is the case then it would be really helpful if that was mentioned somewhere in the documentation.

alazier commented 7 years ago

If you are running something locally on port 8082 then this is probably conflicting with the debug server which is trying to run on the same port. You can try changing the port which is used. On iOS you would need to change the port used here: https://github.com/realm/realm-js/blob/master/react-native/ios/RealmReact/RealmReact.mm#L41

paldepind commented 7 years ago

I'm fairly certain that 8081 is the default port. If you look at the React Native documentation that is port they mention: https://facebook.github.io/react-native/docs/debugging.html

alazier commented 7 years ago

Yes that is the port used for react-native. Realm also runs its own RPC server on 8082 to support chrome debugging. We need to do this because some of the features of our apis are not supported by the native module apis provided by react-native.

alazier commented 7 years ago

You can change the port locally for testing purposes - after you npm install realm you can simply change the port in the installed files and in theory that should work.

paldepind commented 7 years ago

Ok. Thank you for the explanation. I was not aware that Realm used a port in addition to the one used by React Native. I'll see if I can get it to working.

But I guess it's not the intention to throw the "Module AppRegistry is not a registered callable module" error. It makes using the app with just normal Chrome debugging impossible.

paldepind commented 7 years ago

I've tried

adb forward tcp:8082 tcp:8082

but it doesn't seems to work.

alazier commented 7 years ago

I'm not sure what the issue is. If you are able to share your project I could try to take a look. From searching online it seems like you could have an error unrelated to Realm in your index.js file which might cause this issue but I'm not really sure. Also just want to make sure you know remote debugging currently only works when using the emulator/genymotion so if you are trying to run on device that could also be causing issues.

alazier commented 7 years ago

Were you able to make any progress with this? Does chrome debugging work for you on a newly generated react-native project which included Realm?

paldepind commented 7 years ago

Sorry for the delay. I highly appreciate the your answers.

When I run the application on my device without remote JS debugging everything seems fine. But when I activate remote JS debugging I get the error I posted in OP.

If I run in an emulator I see exact same. However, after running adb forward tcp:8082 tcp:8082 everything does work in the emulator without errors. So it seems to me like Realm not being able to connect is what is causing the Module AppRegistry is not a registered callable module. error.

I will try setting up Realm in a new react-native project and let you know how it turns out.

paldepind commented 7 years ago

I've just setup a new react-native project by doing the following:

react-native init RealmReactTest
npm install --save realm
rnpm link realm

I then added the line

const Realm = require('realm');

To index.android.js.

When running the project at that point I got the error: Missing Realm constructor - please ensure RealmReact framework is included. I fixed that by following the instructions here.

I now experience exactly the same as what I described in my last post. No problems without debugging enabled and Module AppRegistry is not a registered callable module when it is.

Just for reference: I'm testing on an Android device, I'm using Linux, rnpm is version 1.9.0, Realm is version 0.14.3 and React Native is 0.31.0.

paldepind commented 7 years ago

@alazier Have you had any luck reproducing the issue from the steps I posted above?

alazier commented 7 years ago

@paldepind there is definitely something wrong - when following your steps the required lines are not added to MainApplication.java by rnpm. Can you ensure that the protected List<ReactPackage> getPackages() method returns new RealmReactPackage()? If not adding this line along with import io.realm.react.RealmReactPackage; should fix the issue. I will look into what is going wrong with rnpm.

paldepind commented 7 years ago

Yes. As I mentioned I added the line manually by following the instructions here. So the rnpm problem was quite easily solved. What I'm reporting here happens unrelated to that issue I think.

alazier commented 7 years ago

Were you ever able to resolve this?

paldepind commented 7 years ago

Hello @alazier. No, unfortunately not. Debugging on device is still impossible. Probably same issue as in #571. I'm hoping that maybe #598 will make it possible to at least make debugging possible.

barbarossusuz commented 6 years ago

Still no solution for this issue?

Damnum commented 6 years ago

Same issue here.

Frogmouth commented 6 years ago

Same here. 👍

ruankao-mengxin commented 6 years ago

i can debug on realm 1.31
But nothing else

Looveh commented 6 years ago

I am able to do remote Chrome debug on an iOS device with 1.10.1 and React Native 0.45.1 but encounter this problem when the app is woken up through Bluetooth State Restoration, which makes it impossible to debug Bluetooth issues and unfortunately is a deal breaker for us.

Is there any plan on fixing this issue? Otherwise we will unfortunately have no other choice but to look for alternative database libraries.

MrHubble commented 6 years ago

@shanghongshen001 did you mean realm 1.3.1? I'm on 1.11.0 and I still have this problem with Android (but not iOS).

ruankao-mengxin commented 6 years ago

@MrHubble I can run and debug on 1.3.1 . The update to 1.10.1 will not be done. I don't know why not. On windows10 , android ,rn 0.45.1

rexxars commented 6 years ago

This still seems to be an issue. After about 30 seconds, I get a timeout error: POST http://77.18.14.132:8083/create_session net::ERR_CONNECTION_TIMED_OUT

What's interesting is that the IP reported seems to be the public IP of my 4G connection instead of the wifi connection as is probably intended.

Edit: Oh, it looks like it's doing 4 attempts against the 4G connection IP and two against the IP of what I assume to be the phone. The first phone-request fails, but the second somehow succeeds. After that it seems to be working (until the next start)

brithbutter commented 6 years ago

Does this issue fixed? I am facing same problem

paldepind commented 6 years ago

@brithbutter I don't think so. We had so many problems with Realm on React Native (this one, in particular, performance, etc) that we moved to react-native-sqlite-storage. We have been happy ever since.

leurias commented 6 years ago

same issue :(

stlemon commented 6 years ago

same+1

duxiwei commented 5 years ago

the same problem

youngjuning commented 5 years ago

465

tangyaogang commented 4 years ago

same issue here

whalemare commented 3 years ago

same issue

kneth commented 3 years ago

We have reworked the Chrome debugger support, and I suggest an upgrade to v10.1.x.

I am closing the issue but it is still observe, please create a new issue.