remcoder/chronos

Error: TypeError: Cannot read property 'destroy' of undefined

MichelFloyd opened this issue · 4 comments

I installed chronos in my app yesterday at Rahul's recommendation at the Meteor DevShop. Things seemed to be looking good (my pages were reacting to time passing) but then a bunch of things broke and I noticed this in inspector:

Error: TypeError: Cannot read property 'destroy' of undefined
at http://localhost:3000/packages/remcoder_chronos.js?9d17e85fb95f3419f5249be9494ebe37472d7d67:86:19
at http://localhost:3000/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:296:31
at Object.Tracker.nonreactive (http://localhost:3000/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:593:12)
at Tracker.Computation.invalidate (http://localhost:3000/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:295:15)
at Tracker.Computation.stop (http://localhost:3000/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:312:10)
at attrTeardown (http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1542:26)
at TeardownCallback.go (http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:199:11)
at HTMLSpanElement.$jq.event.special.(anonymous function).teardown (http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:255:13)
at Object.jQuery.event.remove (http://localhost:3000/packages/jquery.js?dd8bac56f8fd3666d433d2285ae01e52597cc51a:4503:48)
at Function.jQuery.extend.cleanData (http://localhost:3000/packages/jquery.js?dd8bac56f8fd3666d433d2285ae01e52597cc51a:5741:22)

The offending line is:

_timers[cid].destroy();

I'm using Chronos.currentTime() in the query for specific collections, ex:

Template.fooList.helpers({
  cursor: function(){
    return FooCollection.find({expires: {$lt: Chronos.currentTime()}});
  }
});

I'm not using any of the other features of Chronos yet.

A side consequence of this bug is that templates don't get unloaded properly and so can't be reopened later :(

ok, I figured this out. comp.invalidate is being called twice for certain computations so the second time there is nothing to destroy. I'll fork and make a pull request.

Actually, it's weird that comp.onInvalidate is being called twice. The docs explicitly say it's a 'one-time callback'. Or am I misreading something?

oh well.. :-P

It is weird. I was looking at the cid that was being destroyed and sure enough I would see it being created once then destroyed twice.

It could be a peculiarity of my app and/or the packages I’m using. Where I saw it occur first was when closing a bootbox modal.

On May 31, 2015, at 11:09 AM, Remco Veldkamp notifications@github.com wrote:

Actually, it's weird that comp.onInvalidate is being called twice. The docs explicitly say it's a 'one-time callback'. Or am I misreading something?

oh well.. :-P


Reply to this email directly or view it on GitHub.