-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is Async somehow dependent on timers ? #609
Comments
Yes, async uses timers in the browser (basically wherever |
Well, I am running these tests in NodeJS. Are you sure about using Edit: Yeah, just verified,
I don't fully understand why it is done this way, but it goes through this path during tests because |
Isn't it sinon issue?
|
How is that sinon issue ? It has access only to the global Also I would like to save some headache to other people who run into this. It's really hard to debug since the code just stops doing anything. Even if the Sinon would have included some sort of option to skip faking The solution above is rather weird and I cannot seem to understand what is different in IE10 that |
@FredyC , did you try to add |
@rlidwka Of course that works, but that's not the point. Read my previous post again, especially second paragraph please. |
Let me rephrase... You're using a framework to delay timers, and complaining that timers are delayed. Correct? |
It's not really about delay, but to control time during tests. Since my code is working with |
And to be more specific...it's not about me and my issues, not at all. I am just trying to save other people time if they run into same issue as me. Can you tell my what you don't like about my solution? Actually my fix should even improve performance, because this way it looks for |
setImmediate is actually a recommended way of deferring callback in asynchronous api. "recommended" means a lot of libraries use it. Thus, "fixing" it here doesn't really solve anything. If you think it's a bug, it's probably worth to bring it up on Sinon issue tracker. Maybe avoid replacing setImmediate or something like that. |
Ok, I give up, you are just not listening and just avoiding any explanation to my questions. Thanks for your time. |
Btw, what do you mean it doesn't solve anything? It fixes exactly that issue I have said, that code doesn't get stuck no matter what. No fix to Sinon can do that, this is just the issue of Async solution that calls current global |
FreddyC's comment " I am just trying to save other people time if they run into same issue as me." was right on the money. This issue just cost us a pile of time. Some of our Mocha tests written some time ago by devs on our team use sinon to manipulate the date much like FredyC describes. This caused our services that use Async.Auto() to fail on the final callbacks - but only while being run via Mocha. This took us quite a while to chase down. This is the same issue here that was closed with no dialog: #106 This Sinon timer thing might be called out as a known issue in the main readme or some other documentation if no code fix is possible. |
There is a fix and I have made pull request, but it was basically denied without explanation why it's bad solution... I hope this proves my point that it needs some kind of solution, not just ignorance. |
Sounds like the fix is to do |
Well it took quite a while to accept this solution. Thank you! |
I have run into rather weird issue. I am using SinonJS to write my unit tests. There is some neat utility to fake timers. Today I was totally stumbled when my tests became somewhat "stuck". I run them and nothing happened, process was just hanging there and doing nothing.
I started digging and find out that if I don't use fake timers, it works, but since I need to control time in my tests, I started digging more and found out that Async is probably forcing asynchronous behavior with real timers. Check out this JSFiddle.
It's rather innocent piece of code that is not even asynchronous and you can see resulting message in console. However once you remove comment on first line with fake timers, it doesn't finish.
For now I had to get rid of
waterfall
and it started working as expected. I suppose that nothing can be done about this :(The text was updated successfully, but these errors were encountered: