Coder Social home page Coder Social logo

Comments (20)

raix avatar raix commented on May 17, 2024

I have to check up on this, Meteor.users is a bit special since it resumes methods by itself - the error from live data is Meteor throwing errors for data already found - its an odd thing on the client grounddb overwrites the original meteor code to make offline work. Is the error thrown on client or server?

from ground-db.

akralj avatar akralj commented on May 17, 2024

The error is thrown on the client. On further investigation it looks like it has nothing to do with Methods being resumed. I added
GroundDB.skipMethods { "/users/update": true}
to my code so that the update method is not being cached, but still the same error is being thrown. So it must come from the Meteor.users Collection being automatically synced back to the server once meteor is online again.

from ground-db.

akralj avatar akralj commented on May 17, 2024

I came back to the issue and found that any update to any collection (Meteor.users or a normal one) made offline throws the above error:
Uncaught Error: It doesn't make sense to be adding something we know exists.
I could reproduce it in your playground app (see screenshot):
grounddb error

from ground-db.

raix avatar raix commented on May 17, 2024

Nice catch, I guess it's time for adding client-side conflict resolution, I'll have a look at it next week or so. I'll refactor groundDB at the same time.

from ground-db.

akralj avatar akralj commented on May 17, 2024

Hi Morten,
great to hear that you are on it. I was thinking a lot how to implement it myself, but syncing of databases seems is to big of a task for me at the moment.
I have a few questions regarding how grounddb works internally.

  1. Is it correct, that the whole collection is written into localstorage every time an item of the collection changes?
  2. It seems like the current implementation of grounddb can't handle offline changes at all (meteor, does the changes by itself, but this does not work when page was reloaded). Is this true?
  3. Is it correct, that when a user comes from offline (either page refresh or coming from an backgrounded ios page) that the whole collection is transferred to the client again. Or do you do some diffing between the data which was loaded from localstorage and the data which comes from the wire after a reconnect?

I don't really understand how a sync between offline (e.g. localstorage) <-> minimongo <-> mongo should be working, without having some sort of special collection, which logs each change with a version number + timestamp and sends it to the relevant data stores. What are your plans on this one?
Please tell me if my questions are not clear enough.
Thanks andrej

from ground-db.

raix avatar raix commented on May 17, 2024
  1. Nope not every change, if you do multiple changes it will only save once. But the current version does save the whole collection into one localstorage item. It uses minimax to compress, but ideally it should one doc pr. Item. And work async.
  2. It's a bug, discussed in #22 it will be fixed as part of the refactoring
  3. Meteor does not support session resume, i think they will at some point - but i have been thinking about this as part of a custom groundDB publish. But again it's also kind of Nice to get all the data making sure that the local db is not corrupted - ideally this should not be nessesary and we could save bandwidth.

So groundDB is just caching the db and method calls allowing it to resume. The current solution dont have any interface for conflict resolution. It's the tricky part and vary between apps.

from ground-db.

akralj avatar akralj commented on May 17, 2024

Hi Morten,
do you have any plans to tackle this?
I had another look today an saw, that grounddb works perfectly when no user is logged in. the moment one logs in everything works fine(adding, removing records), apart from updates with throw a similar error like before:
Uncaught Error: Server sent add for existing id: 7qsQfsz2boCQakN7q livedata.js
the strange thing is that the change gets applied on the server, but the record which changed in the local collection is wipped out temporarily and only shows up on refreshing the browser (resubscribing!).
any idea what this could be?
cheers andrej

from ground-db.

raix avatar raix commented on May 17, 2024

I'm not sure - but I'm going to dig into it soon - Got some deadlines at the moment, but have to use groundDB for a project with deadline within 30 days - so something is bound to happen...

from ground-db.

timbrandin avatar timbrandin commented on May 17, 2024

I have the same issue on another collection, so it's not just related to the users collection.

from ground-db.

raix avatar raix commented on May 17, 2024

I've just pushed the new ground:db - I havent had time yet to test this issue further - It'll prop. be a couple of days before I get to it - so help is much welcome

from ground-db.

tagrudev avatar tagrudev commented on May 17, 2024

Hello @raix , did you manage to dig into this ?

I have a project with GroundDB and appcache - Once I log in I do GroundDB(Meteor.users) (on the client side) which successfully inserts the information in the localStorage. But once I go offline and refresh the page -

Meteor.user() - returns undefined ( although the information stays in the storage )

from ground-db.

raix avatar raix commented on May 17, 2024

Its on the todo list - I have to add this to the QA test and figure out whats causing the issue :)

from ground-db.

tagrudev avatar tagrudev commented on May 17, 2024

Would very much appreciate that :) 👍

from ground-db.

tagrudev avatar tagrudev commented on May 17, 2024

Hmm I've managed to make it work nothing is different though - I just put the GroundDB('users') -> inside lib/collections/users.coffee and I publish the user collection. Now I can't reproduce the failing 🔢

from ground-db.

raix avatar raix commented on May 17, 2024

So at the moment grounddb is pretty dumb in relations to the user collection - it should wait committing changes when the user that committed those changes logs in... for now it waits 500ms https://github.com/GroundMeteor/db/blob/Meteor-0-9-1/groundDB.client.js#L733-L740

Not sure if this could be the issue - ground:db actually could intercept the meteor.apply 'login' and wait for it to return (if called on connection) - a better solution than a simple wait...

// I still havent added a qa test for grounding the users collection - its on the todo :)

from ground-db.

isAlmogK avatar isAlmogK commented on May 17, 2024

I'm using meteor users and not getting any errors well test some more.

from ground-db.

markshust avatar markshust commented on May 17, 2024

appears to be an issue with fast-render and grounddb. related thread kadirahq/fast-render#80

EDIT: never mind my stupidity, this was due to a circular ref

from ground-db.

sasikanth513 avatar sasikanth513 commented on May 17, 2024

Same issue on different collections too any temporary fix for this?

from ground-db.

sasikanth513 avatar sasikanth513 commented on May 17, 2024

@raix any update on this?

we're frequently getting Server sent add for existing id: LC6G5kzN44STKeLgz:4745 warning and our app crashes

from ground-db.

mitiaptest avatar mitiaptest commented on May 17, 2024

+1

from ground-db.

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.