Trouble with reactivity/DDP connections after upgrade to 1.4


#1

Recently our team decided to update Meteor to 1.4, but we encounter some problems with reactivity, even on simplest publications. One of the examples is out group management view, which relies on following publication:

Meteor.publish('GS.Accounts.Publications.getGroupUsersPublic', function (groupId) {
    check(groupId, String);
    this.unblock();

    if (!this.userId) throw new Meteor.Error('403', 'Forbidden');

    var user = Meteor.users.findOne(this.userId),
        params = {};
    var group = GS.X.Collections.X.findOne(groupId, {fields: {accountId: 1}});
    if (group.hasOwnProperty('accountId')) {
        params['account.id'] = group.accountId;
        params['roles.' + groupId] = {
            $exists: true,
            $ne: [[], '']
        };
    }

    if (user && !user.roles.hasOwnProperty(groupId)) throw new Meteor.Error('403', 'Forbidden');
    
    return Meteor.users.find(params, {
            fields: {
                profile: 1,
                account: 1,
                roles: 1,
                emails: {$slice: 1},
                'services.google.picture': 1,
                customProfileImage: 1
            },
            sort: {
                'profile.firstName': -1
            }
        });
});

And when trying to reactively update some content on client (group edit form, having simple autorun in the code), we get following error:

Exception in flushing DDP buffered writes: Error: Expected to find a document to change
    at Object.update (http://localhost:3000/packages/mongo.js?hash=ed0b13aca2f180af120dd0cfdba64ac79e2a624f:246:29)
    at Object.store.(anonymous function) [as update] (http://localhost:3000/packages/ddp-client.js?hash=27502404fad7fc072e57e8b0b6719f40d92709c7:3613:48)
    at http://localhost:3000/packages/ddp-client.js?hash=27502404fad7fc072e57e8b0b6719f40d92709c7:4441:19
    at Array.forEach (native)
    at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?hash=27b3d669b418de8577518760446467e6ff429b1e:149:11)
    at http://localhost:3000/packages/ddp-client.js?hash=27502404fad7fc072e57e8b0b6719f40d92709c7:4440:13
    at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?hash=27b3d669b418de8577518760446467e6ff429b1e:157:22)
    at Connection._performWrites (http://localhost:3000/packages/ddp-client.js?hash=27502404fad7fc072e57e8b0b6719f40d92709c7:4437:9)
    at Connection._flushBufferedWrites (http://localhost:3000/packages/ddp-client.js?hash=27502404fad7fc072e57e8b0b6719f40d92709c7:4423:10)
    at http://localhost:3000/packages/meteor.js?hash=ae8b8affa9680bf9720bd8f7fa112f13a62f71c3:1105:22

It happens for many reactive views and is not related to data volumes in each collections or database size as a whole (happens on pure, bootstrapped DB too).

We did not encounter such errors on previous version (1.3.2.4). Our MongoDB version is 2.6.9.


#2

It seems that throttling publication by some given amount of time helps.
I think it’s due to the fact that some operations are consumed by DDP transport due to throttling introduced some time ago. If we delay specific action (e.g. deletion), it works as order of operations is preserved and nothing disappears. However, if it’s not and we have multiple operations close to each other (especially remove operation next to change operation), some of them are lost and hence inability to change document that is not present despite the fact it should.
Is there any more convenient solution that throttling some specific changes in handler.observeChanges ?


[Meteor 1.3.4.1] "Exception in flushing DDP buffered writes" when displaying lot of data
#3

@StingRay are you able to reproduce the problem in a sample github repository and report it here https://github.com/meteor/meteor/issues ?


#4

I am getting this error too. We are only a few queries and a few actions. It will work correctly at random times. Working to isolate the issue.


#5

@kylepierce @StingRay check my answer from here. Hope it help