Skip to content

fix: make sink::With send after inner sink returns ready#2976

Open
quasi-coherent wants to merge 1 commit intorust-lang:masterfrom
quasi-coherent:qcoh/with-poll-ready
Open

fix: make sink::With send after inner sink returns ready#2976
quasi-coherent wants to merge 1 commit intorust-lang:masterfrom
quasi-coherent:qcoh/with-poll-ready

Conversation

@quasi-coherent
Copy link
Copy Markdown

If I understand how Sink is supposed to work, a call to start_send has to immediately succeed a call to poll_ready that returns Poll::Ready(Ok(()). Any yield between poll_ready and start_send invalidates readiness of the sink because it could become unavailable during the intermediate polling. At least that's what seems "right" and how I read the documentation.

Currently in With, the future containing the next item is polled after the inner sink's initial Poll::Ready, which could mean that it becomes un-ready while polling for the item, then sent the value when it is unavailable.

The PR changes the helper method to call poll_ready on the inner sink, then immediately start_send the item. Unfortunately that means that the item has to be buffered in the intervening time, which leads to breaking changes in the Debug and Clone implementations.

The PR that introduces the current implementation seems to pretty plainly say that it's following the sink semantics, whereas before it was not. But before !1880 is more like what this PR is doing, so I could be way off. That would be fine too, since I'd appreciate having any of my misconceptions of Sink corrected.

@rustbot rustbot added A-sink Area: futures::sink S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-sink Area: futures::sink S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants