Open
Description
As shared here, channels could potentially deadlock if the capacity isn't large enough:
let (s, r) = channel(1);
s.send(1).await;
s.send(2).await; // this will hang indefinitely
Instead we should probably mention that by using future::timeout
this can be prevented from hanging indefinitely:
let (s, r) = channel(1);
future::timeout(s.send(1), Duration::from_secs(1).await);
future::timeout(s.send(2), Duration::from_secs(1).await);
Perhaps we could even mention in the docs that folks should probably default to something spacious such as 256
or 1024
messages in case of doubt. In general we probably shouldn't assume people have intuition about channels, and nudging them towards some safer default choices (because unlike with unbounded channels they have to choose) wouldn't be a bad idea probably (: