-
Notifications
You must be signed in to change notification settings - Fork 576
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
"Realm at path already opened with different sync user" upon reopening with identical configuration #6461
Comments
@craigdrayton From reading the documentation of Expo TaskManager it is unclear if a task is a thread or a process. The error message you see indicates that it is a process, since Realm currently doesn't support multi-process access for synced Realm (work in process but it will take some time before it is released). You might consider using the same trick as our Electron users apply: One process handles device sync, and other processes open the Realm with the sync configuration set to true (yes, literally |
Thanks for your reply @kneth, really appreciate the help. When I try the following in the background task:
I get: If I pass the following config to RealmProvider in React Native:
I get: |
Downgrading to Realm I haven't been able to get the But it looks like I have a different workaround working: using a different realm path for the background tasks from the foreground React realm. Items added via the background realm are synchronized to the foreground realm.This works in Realm 11 but not Realm 12. |
Yes, for v12, you can use |
Closing this as stale. Feel free to reopen if you have more questions/Kenneth's suggestion didn't work. |
How frequently does the bug occur?
Always
Description
I have a React Native app with Realm and Device Sync configured as per the starter docs.
I am trying to use Expo TaskManager to run a background task where location data is written to Realm.
The background task runs in global context, outside of React, so I cannot access use hooks to access the Realm context.
So I attempt to connect to the Realm with
Realm.open()
, using identical configuration and theapp.currentUser
(anonymous auth) but I get this error:TaskManager: Task "LOCATION_TRACK" failed: [Error: Realm at path '/data/data/[redacted]/files/mongodb-realm/[redacted]/[redacted ID]/flx_sync_default.realm' already opened with different sync user.]
I understood from this comment that I should be able to open the Realm twice successfully without error:
#6273 (comment)
Stacktrace & log output
Can you reproduce the bug?
Always
Reproduction Steps
Create an expo app with Realm and Device Sync configured as per the starter docs.
Realm works correctly inside React using hooks.
Attempt to open the Realm outside the React context, using the same config, and get the error.
Version
^12.6.0
What services are you using?
Atlas Device Sync
Are you using encryption?
No
Platform OS and version(s)
Windows
Build environment
No response
Cocoapods version
No response
The text was updated successfully, but these errors were encountered: