Skip to content

Conversation

@ReubenBond
Copy link
Member

@ReubenBond ReubenBond commented Feb 26, 2025

The norm in .NET is that if cancellation is triggered while awaiting enumeration of an IAsyncEnumerable<T>, that will result in an exception being thrown.

The current behavior in the AsyncEnumerable<T> class is that it ends enumeration instead (as though there were no more items). This is more graceful and results in less exceptions being thrown during shutdown, but it's not the normal or expected behavior.

This PR aligns AsyncEnumerable<T> to the normal .NET behavior, causing cancellation to throw instead or ending enumeration without an exception.

Microsoft Reviewers: Open in CodeFlow

@ReubenBond ReubenBond force-pushed the shutdown/fix-asyncenumerable-cancellation-behavior branch from 2d21b3b to 52822ae Compare February 26, 2025 20:10
@ReubenBond ReubenBond force-pushed the shutdown/fix-asyncenumerable-cancellation-behavior branch from f4cc48d to 3de1a53 Compare March 20, 2025 19:15
@ReubenBond ReubenBond merged commit 49ccf06 into dotnet:main Mar 20, 2025
24 of 25 checks passed
@ReubenBond ReubenBond deleted the shutdown/fix-asyncenumerable-cancellation-behavior branch March 20, 2025 19:21
@github-actions github-actions bot locked and limited conversation to collaborators Apr 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant