Randomly occurs with Meteor: "TypeError: Cannot read property 'invalidate' of undefined" -
on seems random occasions, when user on website tries answer question on quiz page, following error occurs:
typeerror: cannot read property 'invalidate' of undefined @ tracker.dependency.changed (tracker.js:388) @ reactivevar.set (reactive-var.js:82) @ null. (builtins.js:22) @ view.js:191 @ function.template._withtemplateinstancefunc (template.js:437) @ view.js:190 @ object.blaze._withcurrentview (view.js:523) @ viewautorun (view.js:189) @ tracker.computation._compute (tracker.js:294) @ tracker.computation._recompute (tracker.js:313)
i unsure why occurs, , not entirely sure when error means if point me in right direction, great!
note: error seems occur when using chrome.
i'll hazard guess, here's culprit code in tracker.dependency
tracker.dependency.prototype.changed = function () { var self = this; (var id in self._dependentsbyid) // comment - we're expecting `tracker.computation` has `.invalidate()` method! self._dependentsbyid[id].invalidate(); };
so, problem something modifying object.prototype
.
eg.
object.prototype.test = function(){} var emptyobj = {}; (i in emptyobj) console.log('has key=', i, 'isownproperty?=', emptyobj.hasownproperty(i))
will print out:
has key= test isownproperty?= false
a possible solution try, adding snipped client, , seeing if fixes problem (at least temporarily):
tracker.dependency.prototype.changed = function () { var self = this; (var id in self._dependentsbyid){ if (self._dependentsbyid.hasownproperty(id)){ self._dependentsbyid[id].invalidate(); } } }; tracker.dependency.prototype.hasdependents = function () { var self = this; for(var id in self._dependentsbyid) if (self._dependentsbyid.hasownproperty(id)) return true; return false; };
however - it's bad practice add object.prototype
, , lots of code fail in unexpected ways. you'll need track down.
Comments
Post a Comment