Debugging Tracker


#1

I am trying to debug issue when tracker is not firing, even as Collection is receiving new entries. Is there a way how to debug it? How can I see into what Tracker is expecting and why is it not invalidating?

Basically my setup is like that:

  1. big series of javascript functions are executed to set up general environment
  2. it has a list of items to look for, it goes in a for cycle between items A and B
  3. It executes find in collection and expects to find something for A (and then B in next iteration of loop).
  4. if items are found, then for each of the items something is done.

points 3 and 4 are in autorun. In logs I can see that first time 3 is executed twice, but items are not found, as collection has not yet retrieved them.

then after a little while, point 3 is executed again, as Item A is found. But somehow it is never executed second time, for item B. Even as it ends up in the collection.

Maybe the problem is with the for loop? Can for loop create several tracker blocks for each iteration? Any resources to read on how does it work?


#2

Ok, looks like I managed to fix my bug. Replaced for loop with forEach and it started working as expected. It feels like before autorun block was also registered twice, but both times with scope of A, now it is registered twice and as expected with A and B respectively.

It would be still interesting to get to know more on how to debug it. How to peek into Tracker.