Meteor-Community-Packages / Meteor-Community-Packages/ground-db

Grounddb throws error, when being used on Meteor.users and with appcache.

Open
#22 20 comments 0 reactions 0 assignees View on GitHub
Make QA test
Dominant language
JavaScript
Stars
569
Forks
77
PR merge metrics
No merged PRs in 30d

Description

Thank you for this great package.
I tested it with a normal collection and it works like a charm. Only Meteor.users seems to be different when having custom fields in it.

I deployed it to: http://grounddbusertest.meteor.com/ + repo at: https://github.com/akralj/grounddbUserTest

Steps to reproduce (with chrome or safari):
1. http://grounddbusertest.meteor.com/
2. login as : 111@111 with password: 111111
3. cut off your network
4. press "reload app" button which changes the collection & refreshes browser
5. reconnect network
6. do Meteor.reconnect() or wait up to 10s
Uncaught Error: It doesn't make sense to be adding something we know exists: 3cKZpRMZmKpRXatwa
livedata.js?a2e72054ba38809f8cac1e9197d52610e3efef8e:4258

groundDB.db.users is being nuked and meteor thinks one is logged out even if Meteor.userId() still exists in localstorage

It seems like Groundb & the normal Meteor sync overlap. I tested it with a a few versions of meteor and grounddb.

Here the main code.

```
if (Meteor.isClient) {
GroundDB(Meteor.users);
Deps.autorun(function() {
return Meteor.subscribe("userData");
});
Template.hello.helpers({
date: function() {
return Meteor.user().date;
},
userId: function() {
return Meteor.userId();
}
});
Template.hello.events({
"click button": function() {
Meteor.users.update({
_id: Meteor.userId()
}, {
$set: {
date: new Date()
}
});
return Meteor.setTimeout((function() {
return window.location.reload();
}), 333);
}
});
}

if (Meteor.isServer) {
Meteor.publish("userData", function() {
return Meteor.users.find({
_id: this.userId
}, {
fields: {
date: 1
}
});
});
Meteor.users.allow({
update: function() {
return true;
}
});
}
```

Contributor guide

Open the contributing guide

Research direction

Start with the reproduction app and the client code around GroundDB(Meteor.users), the userData subscription, and the reload/reconnect sequence. Investigate the interaction between GroundDB and Meteor's normal user synchronization after appcache reload. Done means the reported sequence no longer throws the duplicate-document error and the logged-in user's custom data remains consistent.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.