Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Realm at path *** already opened with a different schema mode in React Native #6773

Closed
bezenson opened this issue Jun 30, 2024 · 4 comments

Comments

@bezenson
Copy link

How frequently does the bug occur?

Always

Description

Hello! I'm developing React Native app with realm.

I'm initializing app with RealmProvider:

 <RealmProvider schema={[RealmList, RealmTask]}>

At some point I've decided to change schema:

export class RealmTask extends Realm.Object<RealmTask> {
  _id: BSON.ObjectId = new BSON.ObjectId();
  completed: boolean = false;
  createdAt: Date = new Date();
  // date: Date | null = null;  <<<< BEFORE
  date?: Date; // <<<< AFTER
  listId!: BSON.ObjectId;
  order: number = 0;
  reminderEnabled: boolean = false;
  title: string = '';
  updatedAt: Date = new Date();

  static primaryKey = '_id';
}

And after that I've got error:

Error: Realm at path '/Users/[user]/Library/Developer/CoreSimulator/Devices/F93F6540-1289-4F0A-9FFC-FAEAE781EDEA/data/Containers/Data/Application/5A6B5E22-3848-4D24-AF59-B7F2B0528A74/Documents/default.realm' already opened with a different schema mode.

I am developing on iOS simulator.

  1. I've tried to delete app
  2. Tried to add deleteRealmIfMigrationNeeded
  3. Deleted this file manually
  4. Launched another clean simulator

Nothing helped. Only if I roll back schema changes.

How can I fix that? Really got stuck with it.

Stacktrace & log output

No response

Can you reproduce the bug?

Always

Reproduction Steps

No response

Version

12.11.1

What services are you using?

Local Database only

Are you using encryption?

No

Platform OS and version(s)

iOS 17.5 Simulator

Build environment

No response

Cocoapods version

1.15.2

Copy link

sync-by-unito bot commented Jun 30, 2024

➤ PM Bot commented:

Jira ticket: RJS-2855

@kneth
Copy link
Contributor

kneth commented Jul 1, 2024

@bezenson Is it possible that you open the Realm without schema or the old schema somewhere else in your app? The error message could hint that.

@sync-by-unito sync-by-unito bot added the Waiting-For-Reporter Waiting for more information from the reporter before we can proceed label Jul 1, 2024
@bezenson
Copy link
Author

bezenson commented Jul 1, 2024

Oh, that's true. I was calling open() in another place. Removing this fixed the issue. Thank you for pointing me out and sorry for bothering :)

@bezenson bezenson closed this as completed Jul 1, 2024
@github-actions github-actions bot added Needs-Attention Reporter has responded. Review comment. and removed Waiting-For-Reporter Waiting for more information from the reporter before we can proceed labels Jul 1, 2024
@kneth
Copy link
Contributor

kneth commented Jul 1, 2024

@bezenson Good to hear that you found the second place

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants