I20150615-07:11:17.859(9)? Exception from sub draftsList id GghnkQkdjNSTyHuQs Error: Match error: Expected object, got undefined I20150615-07:11:17.859(9)? at checkSubtree (packages/check/match.js:275:1) I20150615-07:11:17.859(9)? at check (packages/check/match.js:32:1) I20150615-07:11:17.859(9)? at [object Object].Meteor.publish.Meteor.users.find.userId [as _handler] (app/server/publications.js:44:3) I20150615-07:11:17.859(9)? at maybeAuditArgumentChecks (packages/ddp/livedata_server.js:1617:1) I20150615-07:11:17.859(9)? at [object Object]._.extend._runHandler (packages/ddp/livedata_server.js:950:1) I20150615-07:11:17.859(9)?
at [object Object]._.extend._startSubscription (packages/ddp/livedata_server.js:769:1) I20150615-07:11:17.859(9)?
at [object Object]._.extend.protocol_handlers.sub (packages/ddp/livedata_server.js:582:1) I20150615-07:11:17.859(9)?
at packages/ddp/livedata_server.js:546:1 I20150615-07:11:17.860(9)? Sanitized and reported to the client as: Match failed [400]
I am working on a meteor project and I'm getting this weird error on my terminal.
The problem is when it says Exception from sub draftsList id GghnkQkdjNSTyHuQs Error: Match error: Expected object, got undefined
, the id always changes on page refresh, and are not in my database (nowhere to be seen).
The thing is, everything works find..
Here is my publication-subscription
Publication
Meteor.publish('draftsList', function (options) {
check(this.userId, String);
check(options, {
limit: Number
});
var drafts = Drafts.find({'user._id': this.userId}, options);
return drafts;
});
Subscription
Router.route('/posts/:_id', {
name: 'postPage',
// limit: function () {
// return
// }
subscriptions: function () {
return [
Meteor.subscribe('singlePost', this.params._id),
Meteor.subscribe('userStatus'),
Meteor.subscribe('draftsList'),
Meteor.subscribe('draftsList', {
limit: Number(Session.get('draftsLimit'))
}),
Meteor.subscribe('comments', {
postId: this.params._id
}, {
limit: Number(Session.get('commentLimit'))
}),
Meteor.subscribe('answers', {
postId: this.params._id
}, {
limit: Number(Session.get('answerLimit'))
})
];
},
data: function() {
return Posts.findOne({_id:this.params._id});
},
});
You are subscribing to
draftsList
twice in your route. The first subscription is without any parameters, which will makeoptions
beundefined
instead of an object. Just remove the first subscription and the problem should go away.Also note that using
check
forthis.userId
may work in this case but could cause problems if you were usingwaitOn
in your route. The generally accepted pattern is to return[]
orthis.ready()
whenthis.userId
isundefined
in a publisher which requires an authenticated client.