meteor-partitioner icon indicating copy to clipboard operation
meteor-partitioner copied to clipboard

User's group is lost across Meteor environment callbacks: Meteor.{defer, setTimeout, setInterval}

Open alur222 opened this issue 9 years ago • 4 comments

Hi mizzao I noticed that we can't operate on partitioned collections inside meteor.defer. Were you able to work it out prior to the issue you've posted on Meteor repo https://github.com/meteor/meteor/issues/2221 ?

Please help. Thanks

alur222 avatar Aug 26 '15 12:08 alur222

Yeah, I usually just store the group from Partitioner.group() and then Partitioner.bindGroup explicitly in the defer function.

This is because DDP._CurrentInvocation.get() is undefined in the defer block, so we don't know what user context it is in.

mizzao avatar Aug 26 '15 16:08 mizzao

nice! Thanks! I will try this.

alur222 avatar Aug 26 '15 17:08 alur222

it worked! :dancers:

alur222 avatar Aug 27 '15 18:08 alur222

Let's leave this open as a signpost so that people know about it and as something that we may be able to fix or improve in the future. This would affect Meteor.defer, Meteor.setInterval, and Meteor.setTimeout.

By the way, if you are using Meteor.defer, you may want to just consider the possibility of doing this.unblock() in the method and going on with whatever is happening in the defer block, so you don't have to avoid these gynmastics.

mizzao avatar Aug 27 '15 18:08 mizzao