meteor-collection-hooks icon indicating copy to clipboard operation
meteor-collection-hooks copied to clipboard

Field names lost in async callback

Open micahalcorn opened this issue 8 years ago • 3 comments

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.

micahalcorn avatar Sep 02 '17 20:09 micahalcorn

Server side or client side?

zimme avatar Sep 04 '17 15:09 zimme

@zimme server-side, thx.

micahalcorn avatar Sep 04 '17 17:09 micahalcorn

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.

zimme avatar Sep 06 '17 10:09 zimme