rust-lang / futures-rs

Zero-cost asynchronous programming in Rust
https://rust-lang.github.io/futures-rs/
Apache License 2.0
5.38k stars 622 forks source link

try_join_all does not short circuit for large input #2866

Open stepancheg opened 3 months ago

stepancheg commented 3 months ago

try_join_all documentation says:

If any future returns an error then all other futures will be canceled and an error will be returned immediately

source

However, when try_join_all switches to FuturesOrdered for large inputs, this is not longer the case: implementation processes future results in order, and if first future is slow, and second future is already finished, try_join_all won't return immediately, but will wait for first slow future completion.

@JakobDegen made an example reproducing this issue: playground.