Repository navigation
subscriptions: cancel_and_drain returns a failed cancel write as Err - #1187
Merged
Merged
Conversation
A failed cancel write was logged and the drain went on, so the caller saw it only indirectly. Return it. After a local error (decode, buffer limit) the cancel was left to Drop, which only logs; write it inline instead. In async, the deadline also bounds the write; a write still pending then finishes in its own task and logs. Sync and async. MessageBusStub gains with_failing_sends and with_stalled_sends (async).
This was referenced Nov 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #1167. The reporter's worker uses
cancel_and_drainto settle a request before replacing it, so it needs to see whether the cancel was actually written.Gap. Both
cancel_and_drains logged a failed cancel write and kept draining. The caller saw the failure only indirectly, as a later reset orUnconfirmed. When the stream had already ended with an error on our side (a decode error,BufferLimitExceeded), the call returnedUnconfirmedright away and left the cancel to Drop, which also only logs. A local error doesn't mean TWS has ended the request. In async, the write was awaited before the deadline-bounded drain, so a stuck write (the case #1179 fixed for reconnect) could hold the call well past its deadline.Change (sync and async):
Err(e).cancelledis set before the write, so Drop never writes a second cancel.Rejected/Unconfirmed), but the cancel is written first wherever one is due, so a write failure reaches the caller.timeout_at(deadline). If the deadline passes first, the call returnsUnconfirmedand the task finishes the write. When no receiver is left (deadline passed, or future dropped), the task logs the error.cancel()still returns().MessageBusStubgainswith_failing_sends()and, async-only,with_stalled_sends(). Both are used by the new tests.6.0 behavior change:
docs/migration-6.0.md§19 (15, 16 and 18 are taken by open PRs #1170, #1183 and #1169), plus a CHANGELOGChangedentry.Verified
drain_returns_cancel_write_erroranddrain_after_error_returns_cancel_write_error(sync and async); asyncdrain_deadline_bounds_cancel_write. On the old code the four write-error tests fail and the stalled-write test hangs; with the change, all pass.drain_after_error_is_unconfirmed_and_cancels_on_dropis now..._writes_cancel.cargo fmt; clippy, rustdoc (-D warnings) andcargo build --exampleson all three feature configs;just test(7152 passed, re-run after rebasing onto 6.0: remove Order::fa_profile, basis_points and basis_points_type #1184); integration crates build and pass clippy.