-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
yield_now not completly yields when used with wasm_bindgen #4807
Comments
Considering how |
(If FuturesUnordered is used in your runtime, two yield_now are needed due to this heuristic: rust-lang/futures-rs#2551 (comment)) |
By It's also interesting that, the spawned future is executed up to the edit: wasm test async doc |
Yes, by "your runtime" I mean "whatever runtime you are using". And to be clear, you are using a runtime - async code cannot run without one. I assume that the runtime is defined in one of the wasm crates you are using (you aren't using the Tokio runtime). To give more details regarding what I think is wrong: It sounds like the wasm runtime doesn't check for new IO events if it already has a future that is immediately ready to run. Since your |
tokio:task::yield_now is not compatible to the runtime used by wasm_bindgen_future (see linked issue). |
Version
tokio v1.18.0
Platform
wasm target (wasm_bindgen + wasm_bindgen_test)
Description
See the provided code sample.
When tokio
yield_now
is used, thefetch_with_request
never resolves. Both future performs a few steps, the but fetch_with_request never completes whenyield_now
is used. If I replace it withwasm_timer::Delay
with a 0 Duration, the fetch works as expected and the download completes with either success or error.I'd expect to reach the
unreachable
part of the code and as both spawn_local are async and I'd expect to have some progress on both future in some of the next microtask tick.The text was updated successfully, but these errors were encountered: