Error: RealmConfig::path is required after upgrading React Native + Realm
Hello team,
I’m facing an issue after upgrading React Native and Realm in Android.
The same code base was working fine before the upgrade, but now I consistently get:
`Error: RealmConfig::path is required`
**Environment**
Previously (working setup):
```
"react-native": "0.75.2",
"realm": "^12.13.1"
```
After upgrade (issue appears):
```
"react-native": "0.81.5",
"realm": "^20.2.0"
newArchEnabled=true
hermesEnabled=true
```
After the upgrade, calling Realm.open() with a custom encryption key and file name results in the error:
`Error: RealmConfig::path is required`
Even though I am explicitly specifying a path:
`path: "default-new.realm"`
**Code Snippet**
```
export const DBConfig = async (key) =>
await new Promise((resolve, reject) => {
const keyArray = key.split(',').map(Number);
const encryptionKey = new Uint8Array(keyArray);
Realm.open({
schema: [
DatabaseSchema.User
],
path: "default-new.realm",
encryptionKey: encryptionKey,
schemaVersion: 8,
migration: (oldRealm) => {
if (oldRealm.schemaVersion < 8) {
// migration logic (not needed in my case)
}
},
})
.then((realm) => {
resolve(realm);
})
.catch((error) => {
reject(error);
});
});
```
**Note:**
This issue occurs only on a cold start. The very first time the app launches, Realm throws the error `RealmConfig::path is required`. After that initial failure, all subsequent launches work normally and the database opens without any issues.
1 条评论