Giter Club home page Giter Club logo

Comments (8)

kraenhansen avatar kraenhansen commented on June 13, 2024

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:

  1. 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?

  2. SDK 28 & SDK 33

    What component / package are you referring to here?

  3. Is it all the data in the realm which gets deleted or just the data that was recently written?

  4. 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.

  5. 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?

  6. Would you be able to recover and send us the .realm file extracted from the device after such an event?

  7. Are you using any other Realm SDKs (such as native Realm Swift / Realm Java or Kotlin) in the same app?

  8. 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.

AbdelhakLabyadh avatar AbdelhakLabyadh commented on June 13, 2024
  1. 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.
  2. SDK 28 is Android 9 and SDK 33 is Android 13
  3. All the data in the realm gets deleted.
  4. Either we delete some data or we delete it all.
    Deleting some 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)
     }
    
    Deleting all data:
     const data1: any = useQuery(Class1);
     const data2 = useQuery(Class2);
       await new Promise<void>((resolve) => {
         realm.write(() => {
          realm.delete(data1);
          realm.delete(data2);
         resolve();
        });
      });
    
  5. 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.
  6. We tried to reproduce the bug to send the .realm file, but we didn't succeed. As I said, it's not systematic.
  7. No, we don't use any other Realm SDKs.
  8. 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.

nirinchev avatar nirinchev commented on June 13, 2024

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.

AbdelhakLabyadh avatar AbdelhakLabyadh commented on June 13, 2024

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.

kneth avatar kneth commented on June 13, 2024

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.

AbdelhakLabyadh avatar AbdelhakLabyadh commented on June 13, 2024

default.txt

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.

kneth avatar kneth commented on June 13, 2024

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.

AbdelhakLabyadh avatar AbdelhakLabyadh commented on June 13, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.