Enabling React Native Debug mode causes Error: Must first create RPC session with a valid host from rpc.js:314
See original GitHub issueGoals
Enable React Native Debug mode in order to troubleshoot console errors, set breakpoints, profile app, and monitor network requests.
Expected Results
Mobile app connects to React Native Debugger successfully and I’m able to set breakpoints, profile app, and monitor network requests, view console errors
Actual Results
- Mobile App crashes with the following error
Error: Must first create RPC session with a valid host from rpc.js:314
:19
Mobile App
Sentry Stacktrace
Error: Must first create RPC session with a valid host
File "app:///rpc.js", col 18, in sendRequest
File "app:///rpc.js", col 41, in setTimeout$argument_0
File "app:///JSTimers.js", col 17, in _allocateCallback$argument_0
File "app:///JSTimers.js", col 6, in _callTimer
File "app:///JSTimers.js", col 6, in callTimers
at <unknown>(app:///RNDebuggerWorker.js:2:134503)
React Native Debugger console
Steps to Reproduce
- Run
yarn android
to build react native application and install on device - Shake device to reveal developer menu and select
Debug
. This is successful if the user is not logged in
- Login to account which causes realm database to be initialized
- An exception occurs on mobile app

The crash occurs when the following is called **`Realm.schemaVersion(Realm.defaultPath)`** **`Realm.defaultPath`** displays an error when inspected using React Native debugger. See video below```
## Code Sample
<!---
Please provide a code sample or test case that highlights the issue.
If relevant, include your model definitions.
For larger code samples, links to external gists/repositories are preferred.
Full projects that we can compile and run ourselves are ideal!
-->
```jsx
export const runMigration = ({currentSchema}: {currentSchema: any}) => {
if (!schemas.length) {
return {schemaVersion: 0};
}
**let nextSchemaIndex = Realm.schemaVersion(Realm.defaultPath);**
schemas[schemas.length - 1].schema = currentSchema;
// If -1, it means this is a new Realm file, so no migration is needed
if (nextSchemaIndex !== -1) {
while (nextSchemaIndex < schemas.length) {
const migratedRealm = new Realm(schemas[nextSchemaIndex++]);
migratedRealm.close();
}
}
return {schemaVersion: schemas[schemas.length - 1].schemaVersion};
};
Version of Realm and Tooling
- Realm JS SDK Version: 10.0.1
- Node or React Native: 0.63.3
- Client OS & Version: OnePlus 6 A6003, Android 10
- Which debugger for React Native: React Native Debugger
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:18 (6 by maintainers)
Top Results From Across the Web
Error after installing Realm: Must first create RPC session with ...
Everything still works but this time, when I try to enable Debug Js Remotely from the development menu, I get the error Must...
Read more >Must First Create Rpc Session With A Valid Host - ADocLib
In this part learn to debug React Native apps using Reactotron and Those two tools should cover most of the ground when debugging...
Read more >Debugging React Native with react-native-debugger
This article will help you learn how to use React Native Debugger and aid you build and debug your app quicker. Check React...
Read more >Basic Options for React Native | Sentry Documentation
Turns debug mode on or off. If debug is enabled SDK will attempt to print out useful debugging information if something goes wrong...
Read more >createSession is not defined - MongoDB
However if I use vscode to do debug with the ap… ... to see how realm sdk for react native works. ... Realm[_constants.keys.id]...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thank for reporting. It is a bug that we need to fix.
Started using Realm for a new project this week. Really looking forward for a fix for this one.