arunoda / laika

testing framework for meteor
http://arunoda.github.io/laika/
MIT License
242 stars 38 forks source link

Inconsistent behaviour in a Deps.autorun() #94

Closed gadicc closed 10 years ago

gadicc commented 10 years ago

Hey. This is my first test, so go easy on me :)

I have something like this:

            Deps.autorun(function() {
                var locale = Session.get('locale');
                if (locale)
                    emit('result', locale);
            });

Sometimes it returns the correct answer, but usually I get:

[Error on Client] TypeError: 'undefined' is not an object (evaluating 'history.state.initial')

I'd say 4/5 times it fails with that error. I just keep rerunnning and I get a few passes here and there. Interestingly, if I use emit('result', 1) in the same location, the 1 always goes through (so not a timing issue). Any other variable gives the same problem (even if I set var x=1 in the function and try return it).

Any ideas?

gadicc commented 10 years ago

Oops, nevermind... I think it's a race condition with another autorun for same variable, with iron-router, which is getting into this issue:

https://github.com/EventedMind/iron-router/pull/418