[Repo Assist] fix: async { for x in taskSeq } no longer wraps exceptions in AggregateException#321
Draft
github-actions[bot] wants to merge 2 commits intomainfrom
Conversation
…teException
Replace Async.AwaitTask with a correct awaiting function that unwraps single
inner exceptions from AggregateException, so that try/catch blocks in async {}
expressions see the original exception type.
Also adds two regression tests that verify the fix:
- exceptions propagate without AggregateException wrapping
- catch blocks see the original exception type
Closes #129
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Mar 9, 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.
🤖 This is a draft PR from Repo Assist, an automated AI assistant.
Closes #129
Root cause
AsyncExtensions.fsusedAsync.AwaitTaskto await the task returned byTaskSeq.iterAsync.Async.AwaitTaskalways wraps task exceptions inAggregateException, meaning thattry/catchblocks inasync {}expressions that iterate over ataskSeqwithforcould not catch the original exception type:Fix
Replace
Async.AwaitTaskwith a privateawaitTaskCorrectfunction usingAsync.FromContinuationsthat:AggregateExceptionbefore routing to the error continuationAggregateExceptionas-is (correct for cases with multiple concurrent failures)This is the standard
AwaitTaskCorrectpattern discussed extensively in the F# community (see fslang-suggestions#840).Files changed
src/FSharp.Control.TaskSeq/AsyncExtensions.fs— addawaitTaskCorrect, replaceAsync.AwaitTasksrc/FSharp.Control.TaskSeq.Test/TaskSeq.AsyncExtensions.Tests.fs— 2 new regression testsrelease-notes.txt— entry under v0.6.0AI Disclosure
This PR was created by Repo Assist, an automated AI assistant.
Test Status
✅ Build: succeeded (Release configuration,
netstandard2.1)✅ Tests: 4530 passed, 2 skipped, 0 failed — full suite
✅ New tests: 2 regression tests in
ExceptionPropagationmodule (50 total in AsyncExtensions)✅ Formatting:
dotnet fantomas . --checkpasses