question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enabling React Native Debug mode causes Error: Must first create RPC session with a valid host from rpc.js:314

See original GitHub issue

Goals

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

https://user-images.githubusercontent.com/222459/96701643-bea69400-1388-11eb-911e-9ee8323b2795.png

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

https://user-images.githubusercontent.com/222459/96701668-c2d2b180-1388-11eb-9199-6c48c90085f9.png

Steps to Reproduce

  1. Run yarn android to build react native application and install on device
  2. Shake device to reveal developer menu and select Debug . This is successful if the user is not logged in

image

  1. Login to account which causes realm database to be initialized
  2. An exception occurs on mobile app
![https://user-images.githubusercontent.com/222459/96701643-bea69400-1388-11eb-911e-9ee8323b2795.png](https://user-images.githubusercontent.com/222459/96701643-bea69400-1388-11eb-911e-9ee8323b2795.png)
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```

image


## 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:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:18 (6 by maintainers)

github_iconTop GitHub Comments

9reactions
knethcommented, Oct 26, 2020

Thank for reporting. It is a bug that we need to fix.

5reactions
uriprecommented, Nov 11, 2020

Started using Realm for a new project this week. Really looking forward for a fix for this one.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found