Repository navigation
fix: throw from PushAsync when a queued operation times out - #581
Merged
Merged
Conversation
TPL Dataflow treats an OperationCanceledException from an ActionBlock delegate as cooperative cancellation, silently dropping the item. A HttpClient.Timeout (TaskCanceledException) during push therefore left the operation queued while PushResult.IsSuccessful stayed true. QueueHandler now surfaces canceled jobs from WhenComplete(), and push converts a non-caller cancellation into a TimeoutException. Completed operations are still persisted before the exception is rethrown. A caller-requested cancellation still surfaces as OperationCanceledException. Closes CommunityToolkit#578
docs.automapper.org no longer resolves; the docs moved to docs.automapper.io. This was failing the lychee link check on the docs workflow.
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.
Closes #578
Problem
When a queued operation's HTTP request hits
HttpClient.TimeoutduringPushAsync, the resultingTaskCanceledExceptionis thrown from theActionBlock<T>delegate insideQueueHandler<T>. TPL Dataflow treats anOperationCanceledExceptionfrom a block delegate as cooperative cancellation, so the item is silently dropped andCompletionfinishes normally.AddOperationResultis never called, soPushResult.IsSuccessfulstaystrue, nothing is reported as failed, and the operation remains queued. A subsequentPullAsyncthen throws because of pending operations.Changes
QueueHandler<T>: catchOperationCanceledExceptionfrom the job delegate, remember the first one, and rethrow it fromWhenComplete()so cancellation is no longer swallowed. This also benefits the pull pipeline.OperationsQueueManager.PushAsync: when an operation is canceled but the caller'sCancellationTokenwas not canceled (i.e. a request timeout), throw aTimeoutException(inner = the original cancellation). A caller-requested cancellation still surfaces asOperationCanceledException.docs/in-depth/client/index.md.This follows the issue's suggested option of throwing like other network failures (e.g.
HttpRequestException) rather than adding a synthetic entry toFailedRequests, sinceFailedRequestsis aServiceResponsemap and a timeout has no response.Tests
QueueHandler_JobCanceled_WhenCompleteThrowsPushAsync_Addition_Timeout_Throws_AndKeepsOperationQueuedPushAsync_CallerCancellation_Throws_OperationCanceledExceptionAll three fail without the fix and pass with it. Client test suite passes locally (
Service.Integration_Tests.Delete_NotSoftDeleted_Returns204is flaky in the full run on bothmainand this branch, and passes in isolation).Notes
The related scenario in the issue (server applied the write before the client timed out, retry gets a 412) is not addressed here; it is inherent to at-least-once delivery and is better handled by conflict resolution.