Open
Description
I think SinkExt::send()
is not cancel safe:
- When
send()
is called, theitem
is moved into aSend
(and from there into its innerFeed
) - When the
Send
is polled, it waits until itsfeed
is ready, which in turn waits until the underlyingsink
is ready. - If the underlying sink is not ready and the
Send
is dropped before it becomes ready, theitem
will be dropped with theSend
and never sent to the underlying sink.
I tried to confirm this with a custom Sink
that is not ready for some period of time and a select!
that tries to send()
items to it with a timeout: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=2608a62c8695fbcfbb22d1856bfe930a. The first two items (which time out before the sink is ready) are never delivered.
A couple of questions:
- Is this analysis correct?
- If so, could I open a PR adding an explicit "Cancel safety" section to
StreamExt::send()
's docs to note that it is not cancel safe?