How to log what caused autorun to run?


Hey everyone,

My problem is that some autoruns are fired many times, and i’d like to have a way to quickly check the source.

I wanted to know if something like that was possible :

let reactive_var_1 = new ReactiveVar();
let reactive_var_2 = new ReactiveVar();
let reactive_var_3 = new ReactiveVar();
let reactive_var_4 = new ReactiveVar();

Template.test.onCreated(function () {
    this.autorun(function () {
        console.log('autorun source is : ');

        let do_something_1 = reactive_var_1.get() + 1;
        let do_something_2 = reactive_var_3.get() + 2;
        let do_something_3 = reactive_var_3.get() + 3;
        let do_something_4 = reactive_var_4.get() + 4;
    'click .something': function () {
        console.log('Someone clicked !!');

Output console should look like this :

autorun source is : 
Someone clicked !!
autorun source is : 

This is the source function i’m looking for, which could output my 'reactive_var_3’

Thanks for your help :slight_smile:


This is not something that is provided to you.

It might be possible by creating an error and parsing the stack to see if you can find which dependency changed.
The thing to look for is Dependency.changed()

Or you can keep track of the last seen values and do your own comparisons