Giter Club home page Giter Club logo

Comments (7)

sync-by-unito avatar sync-by-unito commented on June 15, 2024

➤ PM Bot commented:

Jira ticket: RDART-970

from realm-dart.

nielsenko avatar nielsenko commented on June 15, 2024

This line looks odd:

const Uuid().v4(),

Are you using the uuid package? Realm come bundled with sane_uuid. If you use that instead, you can also use Uuid instead of String as primary key on $PlayerCredit.

My bet would be that some code-path is removing the player credit from the match again later.

The transaction guarantees that credit is added to match.playerCredits or not added to the realm at all, at the end of that transaction. Actually you don't need realm.add(credit); as that is implied by match.playersCredits.add(credit); What happens after I cannot attest to.

from realm-dart.

nirinchev avatar nirinchev commented on June 15, 2024

Are there any errors in the server logs related to the match or the credit document? I'm wondering if it's possible that the player credit got removed from the match either due to a validation error or due to a change somewhere.

Another thing to consider is whether you want the PlayerCredit object to be an embedded object - that is, it won't be able to exist independently of a parent. In json, that would be represented as a nested object/document. That way the entire playerCredits collection will be contained in the match.

from realm-dart.

geosebas avatar geosebas commented on June 15, 2024

Are there any errors in the server logs related to the match or the credit document? I'm wondering if it's possible that the player credit got removed from the match either due to a validation error or due to a change somewhere.

I got no error for this, both on server and Sentry.

Are you using the uuid package? Realm come bundled with sane_uuid. If you use that instead, you can also use Uuid instead of String as primary key on $PlayerCredit.

I do use uuid, but I don't think it's related. I started using it before realm so I kept it.

My bet would be that some code-path is removing the player credit from the match again later.

I do remove it somewhere in my code, but it's too in an transaction.
I agree I assumed that my problem came from the add function, but it may come from this one when I remove it.
Here the code :

      final credits = match.playersCredits.where((element) => element.player?.id == oldPlayer.id).toList();

      if (credits.isNotEmpty) {
        match.playersCredits.removeWhere((element) => element.player?.id == oldPlayer.id);
        realm.deleteMany(credits);
      }
      await transaction.commitAsync();
      await realm.syncSession.waitForUpload();

The transaction guarantees that credit is added to match.playerCredits or not added to the realm at all, at the end of that transaction.

I agree that since in transaction it should be ok.

Actually you don't need realm.add(credit); as that is implied by match.playersCredits.add(credit); What happens after I cannot attest to.

Oh I didn't know about this, thanks for the tip !

from realm-dart.

nirinchev avatar nirinchev commented on June 15, 2024

If you're able to reproduce this while collecting trace level logs on the client, that would help a lot to try and identify the root cause.

from realm-dart.

geosebas avatar geosebas commented on June 15, 2024

Unfortunately, I never managed to get any log on this issue.
I posted here more in hope that you know about some issue like a race condition on array or anything that may be linked to this.
If u don't, I think I will just re-design this part to avoid this problem !

from realm-dart.

github-actions avatar github-actions commented on June 15, 2024

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

from realm-dart.

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.