realm-js
realm-js copied to clipboard
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 [email protected] 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
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
@djgoulart Thanks for reporting! Can you confirm that node_modules/realm/react-native/android/src/main/jniLibs/
has something in it? There should be 4 folders containing librealm.so
@djgoulart Thanks for reporting! Can you confirm that
node_modules/realm/react-native/android/src/main/jniLibs/
has something in it? There should be 4 folders containinglibrealm.so
@takameyer Yes there are 4 folders with 1 file each.
@djgoulart Ok thanks, I am also able to reproduce this, with and without expo. Will continue to investigate why.
@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.
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
@takameyer I would like to help more. Askme if you need anything.
@djgoulart we are working hard on a new release, which will solve this issue. Please be patient 🙂
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
Just waiting for you 10.20.0-beta.6, my darling !!!!!!!!!
Hello, really looking forward to the new version :) In the meantime: @takameyer can you give us any hint on how we can bypass the error for now?
I've upgraded a stable React Native project (from: "react": "^16.13.1", "react-native": "0.63.3", "realm": "^10.2.0"
(+ many other libraries) --> to: "react": "^17.0.2", "react-native", "0.67.3", "realm": "^10.19.2"
(I've tried different realm version also 10.20.0-beta.5
)).
Currently the app is crashing on reproducible occasions, because of the "Missing Constructor" issue. This happens even when I go back to the old realm version "realm": "^10.2.0".
In my prior setting, the error did not appear. It seems like the bug appears in combination with another library. I've read the comments in the React Native 0.69 new release thread. Unfortunately I'm neither using 10.20.0-beta.5
nor react-native 0.69
.
Any help appreciated!
@ChrisConway The only current workaround I have is to use Expo 44. There seems to be something in Expo 45 that comes into conflict with realm
. This is, however, not an issue with the -beta
branches. We are working hard to get an -rc
branch completed, which should be compatible with everything.
@takameyer thanks for the quick reply - unfortunately we're not using Expo. But it's good to know, maybe we'll convert. In case I'll find another way, I'll post it here. Thanks again and let me know in case I can help by providing further information.
@ChrisConway Well it should work without expo then. However we do have known issues with react-native-reanimated
v2. Does that happen to be included in your dependencies?
@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",
}
Using RN 0.69 the problem insists even with the "react-native-reanimated" workaround suggested.
@joaotmachado We are currently looking into compatibility issues with 0.69.0
.
@joaotmachado We are currently looking into compatibility issues with
0.69.0
.
@takameyer could you provide any info related to the release of 10.20.0-beta.6? Our company has great expectation on it. It would able us to active the new architecture on RN 0.69 and bring the Android performance to the next level.
Thank you in advance. And let me know if you need any test support.
@takameyer Still showing the same error for android with the new RC release (11.0.0-rc.0) + React Native 0.69.1 - New Architecture = True.
Missing Constructor Error
@joaotmachado It's not currently compatible with React Native 0.69 and greater. We will update the release notes and are currently working on compatibility with the latest React Native.
@ChrisConway I tried to downgrade react-native-reanimated like you did but it gave me a new error A problem occurred configuring project ':react-native-reanimated'.
Configuration with name 'compile' not found.
I'm not using expo and here is my configuration: { "@realm/react": "^0.3.1", "react": "17.0.2", "react-native": "^0.68.2", "react-native-reanimated": "^1.13.4", "realm": "^10.20.0-beta.5" }
Do you know how to solve this issue? Thanks in advance !
We have released 11.0.0-rc.1
which should be compatible with react-native
0.69.1
and react-native-reanimated
@takameyer I have upgraded realm to 11.0.0-rc.1 but there is always the error "Error: Missing Realm constructor. Did you run "pod install"?. I am not using Mac so I am not able to run this command
@tdangexo that's strange. Can you try:
rm -rf node_modules
npm cache clean -f
watchman watch-del-all
rm -rf $TMPDIR/metro*
rm -rf $TMPDIR/react-native*
npm install
Also, does this directory exist? node_modules/@realm/react/node_modules/realm
And finally, can you share your current package.json
@takameyer I tried all given instructions but nothing works. The directory realm exists. Here is my package.json{ "name": "exo.operator", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", "test": "jest", "lint": "eslint . --ext .js,.jsx,.ts,.tsx" }, "dependencies": { "@realm/react": "^0.3.1", "@reduxjs/toolkit": "^1.8.2", "react": "17.0.2", "react-native": "^0.68.2", "react-native-config": "^1.4.6", "react-native-elements": "^3.4.2", "react-native-encrypted-storage": "^4.0.2", "react-native-gesture-handler": "^2.5.0", "react-native-get-random-values": "^1.8.0", "react-native-reanimated": "^2.9.1", "react-native-safe-area-context": "^4.3.1", "react-native-screens": "^3.15.0", "react-native-vector-icons": "^9.2.0", "react-navigation": "^4.4.4", "react-navigation-stack": "^2.10.4", "react-navigation-tabs": "^2.11.2", "react-redux": "^8.0.2", "realm": "^11.0.0-rc.1" }, "devDependencies": { "@babel/core": "^7.12.9", "@babel/runtime": "^7.12.5", "@react-native-community/eslint-config": "^2.0.0", "@types/jest": "^26.0.23", "@types/react-native": "^0.67.3", "@types/react-test-renderer": "^17.0.1", "@typescript-eslint/eslint-plugin": "^5.17.0", "@typescript-eslint/parser": "^5.17.0", "babel-jest": "^26.6.3", "eslint": "^7.32.0", "jest": "^26.6.3", "metro-react-native-babel-preset": "^0.67.0", "react-test-renderer": "17.0.2", "typescript": "^4.4.4" }, "resolutions": { "@types/react": "^17" }, "jest": { "preset": "react-native", "moduleFileExtensions": [ "ts", "tsx", "js", "jsx", "json", "node" ] } }
@tdangexo what version of node
and npm
are you using?
@takameyer node 16.15.1 and npm 8.11.0. In fact when running npm install, it gave me "Could not resolve dependency peer react-native-safe-area-context@"^3.1.9" from [email protected]
node_modules/react-native-elementsreact-native-elements@"^3.4.2" from the root project So i ran npm install --legacy-peer-deps. Maybe it did not work due to this dependency issue?
@tdangexo That's possible. I'll see if I can reproduce this. You building for Android, correct?
@takameyer yeahh I'm building for Android. Thanks a lot for your help !
@tdangexo I am able to reproduce this using our template app and simply installing [email protected]
. So we can rule out the --legacy-peer-deps
idea. It's possible updating React Native will make the issue go away. I'll verify this.