Repository navigation
Keep every inner exception when an async delegate's task faults with several [patch] - #110
Merged
Merged
Conversation
…several [patch] ForwardCompletionAsync awaited the delegate's task, which rethrows only the first of its exceptions, so InvokeAsync(() => Task.WhenAll(a, b)) faulted with one inner exception where the delegate's own task had two. Wait without throwing first and, when the task faulted with more than one exception, hand all of them to the caller's task. Awaiting the call still throws the first, and a single exception keeps its existing mapping (an OperationCanceledException still cancels). Fixes #109 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5chbrSDfDAQ2U7T5G
This was referenced Nov 12, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5jpiuVuBRXSgitSY1
|
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.



Fixes #109
What was wrong
Both
ForwardCompletionAsyncoverloads (behindInvokeAsync(Func<Task>),InvokeAsync<T>(Func<Task<T>>)and theInvokeValueTaskAsyncoverloads) usedawait innerto wait for the delegate's task.awaitrethrows only the first exception, soInvokeAsync(() => Task.WhenAll(a, b))faulted with 1 inner exception where calling the delegate directly gives 2.Change
New helper
TrySetFaultsAsync, called by both overloads before the existingawait:Task.WhenAny(inner), which works on every target framework). When the task faulted with more than one exception, it passes all of them tocompletion.TrySetException(...).OperationCanceledExceptiontherefore still cancels the caller's task instead of faulting it, and anullreturned task behaves as before.await invoker.InvokeAsync(...)and the synchronousInvoke(...)still throw the first exception.Tests
New
AggregateFaultTests, usingTask.WhenAllover two pre-faulted tasks (InvalidOperationException,FormatException):TReturnforms, on the owner-thread (inline) path and on the queued (Task.Run+DoInvokes) path: the task faults with both inner exceptions, in order.InvokeValueTaskAsyncforms.Invoke, still throw the first exception.The five multi-exception tests failed before the fix ("Expected collection to contain a specific number of elements") and pass after it. The full suite passes (83/83), and
dotnet buildis clean on every target.Generated by Claude Code