What would cause a Tracker computation to stop?


#1

I’ve got a strange situation where I have a Tracker computation stopping immediately. I’m using this to track upload progress from edgee:slingshot. uploader.progress() is reactive.

    computation = Tracker.autorun(() => {
      console.log('upload progress =', uploader.progress());
      this.setState({progress: Math.ceil((uploader.progress() || 0) * 100)});
    });

    computation.onStop(function () {
      console.log('why did we stop?!');
    });

The console shows:

upload progress = NaN
FileUpload.jsx:62 why did we stop?!

I don’t understand the conditions under which a computation stops automatically.

EDIT: Oddly enough, even if I make the function totally empty:

computation = Tracker.autorun(() => {});

It still stops immediately.


#2

I hit something like this once and I think it came down to my autorun being inside another autorun. From the docs, “If you nest calls to Tracker.autorun, then when the outer call stops or reruns, the inner call will stop automatically”.

My issue actually happened in the old meteor-react package’s getMeteorState() which wrapped its function inside of an autorun to keep track of reactive variables. Since I see you are calling React’s setState() maybe you are hitting something similar.


#3

Revisiting this issue again… still haven’t the slightest idea why this wouldn’t work.

Looks like I’m not the only one: https://github.com/meteor/react-packages/issues/99

Is this a bug, @sashko?