realm-js: 10.20.0-beta.5 Missing Constructor Error

How frequently does the bug occur?

All the time

Description

I did a clean install of version realm@10.20.0-beta.5 to test if it would work with reanimated2. But from the beginning I got the “Missing Realm constructor” error message.

Im using:

    "expo": "~45.0.0",
    "expo-dev-client": "~0.9.6",
    "expo-splash-screen": "~0.15.1",
    "expo-status-bar": "~1.3.0",
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "react-native": "0.68.2",
    "react-native-web": "0.17.7",
    "realm": "10.20.0-beta.5"```

### Stacktrace & log output

```shell
Error: Missing Realm constructor. Did you run "pod install"? Please see https://realm.io/docs/react-native/latest/#missing-realm-constructor for troubleshooting
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:95:4 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:141:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
at node_modules/@react-native/polyfills/error-guard.js:49:36 in ErrorUtils.reportFatalError
at node_modules/metro-runtime/src/polyfills/require.js:203:6 in guardedLoadModule
at http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.realmexpo&modulesOnly=false&runModule=true:142813:3 in global code

Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:95:4 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:141:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
at node_modules/@react-native/polyfills/error-guard.js:49:36 in ErrorUtils.reportFatalError### Can you reproduce the bug?

Yes, always

Reproduction Steps

You can use the repo below as example and just configure a Sync App. https://github.com/djgoulart/realm-sync-error|url

Version

10.20.0-beta.5

What SDK flavour are you using?

Atlas App Services (auth, functions, etc.)

Are you using encryption?

No, not using encryption

Platform OS and version(s)

Android SDK 32

Build environment

Which debugger for React Native: …

Cocoapods version

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 46 (21 by maintainers)

Most upvoted comments

@djgoulart we are working hard on a new release, which will solve this issue. Please be patient 🙂

Just an update. We have a PR for @realm/react which will fix the missing constructor. We still need an update to -beta to support some missing features on master

Just to register. Similar issue that i`ve commented on React Native 0.69 new release thread. https://github.com/reactwg/react-native-releases/discussions/21#discussioncomment-2965334

I tried everything this realm with the new arch doesn’t work here. =(

@joaotmachado We are currently looking into compatibility issues with 0.69.0.

@takameyer I’m using "react-native-reanimated": "^2.4.1"- before it was "react-native-reanimated": "^1.13.2". However downgrading reanimated back to "react-native-reanimated": "^1.13.2" seems to have fixed the issue. I can confirm that the error is no longer appearing (neither for realm 10.19.2, 10.2.0 or 10.20.0-beta.5). Thank you so much!

My current configuration: "react": "^17.0.2", "react-native", "0.67.3", "realm": "^10.20.0-beta.5", "react-native-reanimated": "^1.13.2"

Hint for anyone else coming across this issue: in order to avoid dependency problems when downgrading reanimated, I needed to disable the react-native-reanimated/plugin:

error index.js: Cannot find module 'react-native-reanimated/plugin'
...
at resolvePlugin (/Users/PathToApp/App/node_modules/@babel/core/lib/config/files/plugins.js:83:17)

-> Inside babel.config.js:

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  //plugins: ['react-native-reanimated/plugin'],
};

@ChrisConway @takameyer I’m using the versions below, and currently I’m not facing this issue. I’m not using reanimated at this moment.

{
    "react": "17.0.1",
    "realm": "^10.19.0",
    "@realm/react": "^0.3.0",
    "expo": "^44.0.6",
}

Just waiting for you 10.20.0-beta.6, my darling !!!

@djgoulart It seems the the @realm/react is not resolving the parent dependency to realm v10.20.0-beta.5 and instead downloading its own. This related to this issue we have witnessed on iOS https://github.com/realm/realm-js/issues/4622 We will be preparing a new release for Hermes soon, as there are updates from master that need to be backported that @realm/react requires.