ccorcos/meteor-subs-cache

Error: Can't set timers inside simulations

Closed this issue · 5 comments

Callstack:

Error: Can't set timers inside simulations
    at withoutInvocation (timers.js:5)
    at bindAndCatch (timers.js:13)
    at Object._.extend.setTimeout (timers.js:29)
    at Object.SubsCache.SubsCache.subscribeFor.cachedSub.delayedStop (subsCache.coffee:89)
    at subsCache.coffee:85
    at tracker.js:263
    at Object.Tracker.nonreactive (tracker.js:560)
    at Tracker.Computation.invalidate (tracker.js:262)
    at Tracker.Computation.stop (tracker.js:279)
    at null.<anonymous> (view.js:203)

Can I get some context? "inside simulation" makes me think something is happening in a Meteor.method...

I start the subscription in a Template.onCreated() (inside this.autorun()) function, to get cached template level subscriptions. If the data for the template instance get removed, the template will be destroyed. The error occurs on destroying the template

Here's a MeteorPad: http://meteorpad.com/pad/MwuA7rasNrd2SGpxN/ccorcos:subs-cache#4
I hope it's okay for you that I used coffeescript.

The error occurs if you click the "x" to remove a player

Hmm. I've never used Template.currentData() but I think thats the issue.

This works:

http://meteorpad.com/pad/FvHmens47jwYLrgrN/Copy%20of%20ccorcos:subs-cache#4