3

During loading my Meteor app my Tracker.autorun function fires too many times. I'd like to inspect what causes that problem, but I cannot even check inside the function what event caused its actual fire. How can I do this?

edit:

If I do console.trace() in my autorun I get this:

(anonymous) @ VM6091:1
(anonymous) @ createStore.js:21
Tracker.Computation._compute @ tracker.js:311
Tracker.Computation @ tracker.js:201
Tracker.autorun @ tracker.js:576
module.export.exports.default @ createStore.js:15
(anonymous) @ main.js:36
maybeReady @ startup_client.js:26
loadingCompleted @ startup_client.js:38

But I still cannot tell what caused loadingCompleted function to fire.

Karol Selak
  • 4,248
  • 6
  • 35
  • 65

1 Answers1

2

During loading my Meteor app my Tracker.autorun function fires too many times.

This means you are changing reactive source that's used inside your autorun function too many times.

1) You can catch changes using browser breakpoints. Just create breakpoint inside your autorun function, and look at call stack.

2) You can log all of functions that changes your reactive sources (Collection, ReactiveVar, etc...)

  • Thanks! I edited my question adding more details, but I'm still stuck. Only reactive sources I have are collections, but I don't modify them really during my app loading. – Karol Selak Nov 27 '17 at 08:58
  • 1
    @KarolSelak do you know that when you create autorun function, this function **runs immediately for the first time**, then it waits for reactive source changes inside autorun function and runs every time when reactive sources are changed? Maybe you are messed up with this behavior. – Shynggys Kengessov Nov 27 '17 at 09:15
  • Okay, I have some new ideas about my problem, but as my question was about debugging I marked answer as working (because it led me on the right path). I'm going to write new question with my real problem soon. Thanks again! – Karol Selak Nov 27 '17 at 20:56