Skip to content

Fix combination callbacks - #1887

Merged
SimonCropp merged 2 commits into
mainfrom
fix-combination-callbacks
Aug 30, 2026
Merged

Fix combination callbacks#1887
SimonCropp merged 2 commits into
mainfrom
fix-combination-callbacks

Conversation

@SimonCropp

@SimonCropp SimonCropp commented Aug 29, 2026

Copy link
Copy Markdown
Member

UseCallbacks combined the callbacks with +=. Invoking a multicast Task returning
delegate returns only the last target's Task, so when UseCallbacks was called
more than once, for example by an extension package plus user code, every
earlier callback ran unawaited: its exceptions unobserved and its async work
racing the combination method. Extensions.Then documents the same hazard for
Func.

They are now held in lists and awaited in order. The no callback path still
returns Task.CompletedTask without allocating.

SimonCropp and others added 2 commits August 29, 2026 17:21
UseCallbacks combined the callbacks with +=. Invoking a multicast Task returning
delegate returns only the last target's Task, so when UseCallbacks was called
more than once, for example by an extension package plus user code, every
earlier callback ran unawaited: its exceptions unobserved and its async work
racing the combination method. Extensions.Then documents the same hazard for
Func<Task>.

They are now held in lists and awaited in order. The no callback path still
returns Task.CompletedTask without allocating.
@SimonCropp SimonCropp added this to the 33.0.0 milestone Aug 29, 2026
@SimonCropp
SimonCropp merged commit 40ecfe5 into main Aug 30, 2026
7 checks passed
@SimonCropp
SimonCropp deleted the fix-combination-callbacks branch August 30, 2026 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants