meteor-collection-hooks
meteor-collection-hooks copied to clipboard
Field names lost in async callback
I've been using this package for years and love it. I'm upgrading to Meteor 1.5, and I'm running to an issue with asynchronous tasks that are called from update hooks.
fieldNames returns ['foo', 'bar']
MyCollection.after.update(function(userId, doc, fieldNames, modifier, options) {
console.log(fieldNames);
});
fieldNames returns ['MONGO_OBJECT_REMOVED', 'MONGO_OBJECT_REMOVED']
MyCollection.after.update(function(userId, doc, fieldNames, modifier, options) {
Meteor.defer(() => {
console.log(fieldNames);
});
});
Cloning the argument helps, but it seems inappropriate to reference every variable that will be used in the asynchronous callback.
fns returns ['foo', 'bar']
MyCollection.after.update(function(userId, doc, fieldNames, modifier, options) {
const fns = [...fieldNames];
Meteor.defer(() => {
console.log(fns);
});
});
Is anyone else experiencing anything like this or have an idea of what might be happening? Google knows nothing about MONGO_OBJECT_REMOVED.
Server side or client side?
@zimme server-side, thx.
I've tried looking around a bit for this and I can't find any reference to MONGO_OBJECT_REMOVED in either this package, meteor or mongodb node driver.
A reproduction repo would probably help to try and track this down.