-
Notifications
You must be signed in to change notification settings - Fork 63
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
something wrong with set_timeout in specs #58
Comments
Hi Jared. When things run async in javascript, we can't have a top level wrapper that will catch issues in all browsers. There is also an instance describe "some async magic" do
async "it might raise an error" do
something_happens_later do
async { raise "yo" }
end
end
end Wrapping things inside that |
Thanks for the helpful tip...doesn't really explain my problem however because I didn't write any of the code that's not working right, particularly the strange set_timeout behavior. :) |
The timeout behaviour is intentional. Maybe it should be renamed though to avoid confusion with |
Thanks Adam, that put me on the right path. I renamed set_timeout to delay (since set_timeout was actually just an alias of delay) and changed the values. I also fixed the other issue you mentioned by putting async { } inside the delay blocks instead of wrapping them. |
Just to follow up, the reason that method deals with seconds instead of milliseconds is that it feels a bit more consistent with other ruby/rails libs: # ruby corelib
sleep(1) # => 1 second
# rails monkey patching
12.seconds.to_i # => 12 |
Yeah, I think it just threw me seeing "set_timeout" since that has such a specific usage in Javascript. And apparently I wasn't the only one confused since the tests weren't working. Less confusing to call it delay. :) Thanks again for the tips. |
I'm trying to run the test suite using rackup in the browser (using latest master), and it seems like something odd is happening with the async/set_timeout stuff. First of all, it seems the numbers are being interpreted as seconds, not millseconds, so set_timeout 400 do will take 400 seconds to run. (I can change it to 4, and it will run in 4 seconds...) Also, when there's an error inside the block, instead of updating the page, it throws an actual error visible in the JS console.
Anyone else able to see this issue?
The text was updated successfully, but these errors were encountered: