-
Notifications
You must be signed in to change notification settings - Fork 146
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
Fix timers in web workers #56
Conversation
Sorry about this! That's a copy-paste error from timeout (from before it was using Maybe these two issues should be split into separate PRs though since they aren't related? |
Apology accepted. Don't let it ever happen again. Now go to your room and put away your clean washing. I want to see the socks FOLDED this time.
Yeah interesting you should say that. I haven't looked at the test suite much but I have some concerns with it too. Namely when I made these changes I ran the test suite and everything passed. But then for the lolz I changed the
Sure - I was just being lazy ;) I'll split the interval fix out now. |
Actually no ... ignore me, I was only running
|
4dc3895
to
5cf8eed
Compare
Ah, I think this is because the integration tests are gated on the recently-added |
|
What's your version of |
Ah good catch, I'm on 0.6 still. |
Relevant: rustwasm/wasm-bindgen#1046 |
…d of the Window API, since window isn't always present (e.g Web Workers)
5cf8eed
to
acb92d9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @samcday.
I think given that we don't have a nice way of representing WindowOrWorkerGlobalScope
via web-sys (yet), writing the bindings by hand makes sense.
Just a nitpick below that needs to be addressed, and then I think we can land this.
Regarding the headless browser tests: as of #54 they are running in CI, so we should be better protected going forward. |
@fitzgen / @OddCoincidence
gloo-timers
doesn't work in web workers at all right now, becauseweb_sys::window()
wants to cast the global namespace into aWindow
object, which doesn't exist in worker contexts. So I just dropped us back down to raw#[wasm_bindgen]
methods.This might be something better fixed in wasm-bindgen later though. There does exist this thing: WindowOrWorkerGlobalScope which is a nice view over what global methods are available in both Window and Worker contexts. However as stated in that documentation:
So I guess this thing is probably not mentioned anywhere in the IDLs that are being used to build the
web-sys
crate.Also, theSee #57Interval
stuff wasn't actually working properly at all, it was consuming the callback from theOption
which meant only the first interval callback worked and all subsequent ones failed.