Comments (8)
Loss of data is of course something we take very seriously, so we're very invested in getting to the bottom of an issue like this.
We do however need a bit more help reproducing this and I have a few questions:
-
keep your app inactive for a long time
How long time are we talking here? Minutes, hours, days?
What is the minimum time elapsed where you've ever observed this behaviour? -
SDK 28 & SDK 33
What component / package are you referring to here?
-
Is it all the data in the realm which gets deleted or just the data that was recently written?
-
Do you have any other code that interact with the database? How are you opening the realm? Etc. I'm curious if any of that code might be causing this.
-
At approximately what frequency do you see this? Let's say you try to reproduce it - how many times (on average) do you need to retry until you see the behaviour?
-
Would you be able to recover and send us the
.realm
file extracted from the device after such an event? -
Are you using any other Realm SDKs (such as native Realm Swift / Realm Java or Kotlin) in the same app?
-
Would you be able to provide an app, with at little code possible which exhibits this behaviour? Either on GitHub or privately via email?
from realm-js.
- We are talking about hours (between 10 and 48 hours)
The minimum time elapsed is about 10 hours.
Sometimes it happens in 15 minutes on Emulator, but not systematic. - SDK 28 is Android 9 and SDK 33 is Android 13
- All the data in the realm gets deleted.
- Either we delete some data or we delete it all.
Deleting some data:Deleting all data:try { await realm.write(async () => { if (myData.length) { myData.forEach((data: dataType) => { if (data.attribute) { return; } else { realm.delete(data); } }); } }); } catch (error) { console.log(error) }
const data1: any = useQuery(Class1); const data2 = useQuery(Class2); await new Promise<void>((resolve) => { realm.write(() => { realm.delete(data1); realm.delete(data2); resolve(); }); });
- Sometimes it happens on Emulator in 15 minutes.
On Real Device, it happens after 10 hours, but not always and not in all devices.
The app has to be closed and no internet. - We tried to reproduce the bug to send the .realm file, but we didn't succeed. As I said, it's not systematic.
- No, we don't use any other Realm SDKs.
- It may be done but it would take time. If you don't succeed to reproduce the bug, let us know and we will work on it.
We hope this information would be helpful.
from realm-js.
Can you share the code you use to open the Realm? Additionally, can you set the log level to trace and capture the logs from an app run that results in a loss of data. Finally, have you verified that the Realm file is still available when the app is relaunched after the period of inactivity?
On a side note, the code you posted that deletes from the database is not particularly insightful without context of how it's being used. If you're calling the "delete all data" method every 5 hours, it would explain why your data is gone after a while. You should probably add some log statements around the code you use to delete data and confirm it's not being accidentally called.
from realm-js.
The problem is that the bug is not systematic and not in all devices.
It happens often in the deployed app in real devices.
We will verify the Realm file next time when the bug happens, we added debugging variables in the deployed app.
For the code we use to open the Realm, we use only the code above. We have read that Realm.write opens the Realm automatically.
from realm-js.
Realm.write opens the Realm automatically.
Realm.write()
handles the transaction but you need to open the Realm elsewhere. We will keep the issue open and wait for you to provide more information once the added debugging variables and logging give results.
from realm-js.
I am sharing with you the .realm file extracted from the device after the event (I had to change it to .txt so I can upload it here, you can change the extension after downloading the file) . All the data are reset.
As you can see, there is a class called Test. This class we just create it to test, we never delete it in the app, but it's deleted also after such an event.
I have to mention that we don't use realm.open at all in our app (it may be a mistake).
Also I have to mention that we experienced a scenario where the data is imported in Realm but the .realm file is not created - We imported the data in Realm, we can see it and manage it in the app but when we went to see the .realm file we didn't find it, we closed the app and open it again, realm re-imported the data.
from realm-js.
there is a class called Test.
Yes, with no objects.
we don't use realm.open
I suppose, you are using new Realm(config)
. Please post config
.
data is imported in Realm but the .realm file is not created
The Realm file will be created when you open the file. Please use Realm.path
to find the file.
from realm-js.
Yes, with no objects.
It has an object which is created after the import of all our data is finished, and we don't delete this object in the app. But it is deleted as you can see.
I suppose, you are using new Realm(config). Please post config.
This is our config:
Schema.ts
const Schema = [Data, Test];
export const realmConfig: Realm.Configuration = {
schema: Schema,
};
Config.ts
import {createRealmContext} from "@realm/react";
import {realmConfig} from "./Schema";
const realmContext = createRealmContext(realmConfig);
export const useRealmContext = () => realmContext;
The Realm file will be created when you open the file. Please use Realm.path to find the file.
The file is not created the 1st time (We checked the file path and we didn't find it), that's why when we closed the app and re-open it, realm imported the data again.
But the 2nd time the .realm file was created after the data import is finished (We checked the file path and we found it). So we closed the app and re-open it, realm didn't import the data again.
from realm-js.
Related Issues (20)
- baseUrl Change
- "not authorized to execute command aggregate out" with createCollection HOT 1
- Application couldn't connect into Primary Node in PSA HOT 1
- Realm not working with nextjs App router HOT 5
- Data loss after migrating to flexible sync affecting first write per realm. HOT 1
- realm-web's `findOneAndDelete` leaves empty document with only _id in collection HOT 1
- Upgrade to Realm Core v13.27.0 HOT 1
- Upgrade to Realm Core v14.1.0 HOT 1
- Jest tests fail with Node version 16 HOT 2
- Improve duplication of realm entities and upsert with relationships HOT 2
- Error: "invalid id token: 'aud" must be a string containing the client_id" in Android Release Build after Publishing to Google Play Store HOT 3
- Upgrading to v12 causes duplicate to be created instead of updated when updating nested object HOT 11
- Device Sync stoped working: could not decode next message: failed to get reader: WebSocket closed: failed to acquire lock: context deadline exceeded HOT 2
- Android 12.6.1: Error: Getting '$$typeof' from binding before it was injected, js engine: hermes HOT 10
- Update prepare / publish workflows to use a GitHub App token HOT 1
- Upgrade `actions/upload-artifact` to v4 and refactoring `pr-realm-js` workflow HOT 3
- RealmProvider fallback taking too much time to load HOT 2
- Use Xcode 15 on GHA HOT 1
- Realm v12.6.2 with React Native v0.73.5, getting link error in iOS build compile HOT 2
- Upgrade to Realm Core 14.2.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from realm-js.