Skip to content

Race timeout/cancellation/signals at the Task level, drop AssumeNeverEmits - #5

Merged
kblok merged 1 commit into
mainfrom
task-based-race-remove-assumenevremits
Jul 31, 2026
Merged

Race timeout/cancellation/signals at the Task level, drop AssumeNeverEmits#5
kblok merged 1 commit into
mainfrom
task-based-race-remove-assumenevremits

Conversation

@kblok

@kblok kblok commented Jul 31, 2026

Copy link
Copy Markdown
Member

AssumeNeverEmits existed to fake timeout/cancellation into Observable branches so they could sit in an Observable-level RaceWith next to real data - a workaround for C# having no bottom type. Turns out that's the wrong layer entirely: these signals never produce a value, so racing them belongs at the Task level, where Task.WhenAny doesn't care what type the branches share. RaceWithSignalAndTimer now returns Task directly (no more trailing .FirstValueFrom()), and there's a new overload for racing against an already-existing "only ever faults" task instead of a CancellationToken.

Bumped to 0.3.0 for the breaking return-type change.

…Emits

RaceWithSignalAndTimer used to force cancellation and timeout into fake
Observable<T> branches (via AssumeNeverEmits) just so they could sit in an
Observable-level RaceWith next to the real data stream - a workaround for C#
having no bottom type. Racing at the Task level instead sidesteps the problem
entirely: Task.WhenAny doesn't care that the branches share a type. Also adds
a Task-signal overload for racing against an already-existing "only ever
faults" task (e.g. a session-closed signal) instead of a CancellationToken.

Bump to 0.3.0 - RaceWithSignalAndTimer/RetryAndRaceWithSignalAndTimer now
return Task<T> instead of Observable<T>, and AssumeNeverEmits is gone.
@kblok
kblok merged commit 7877122 into main Jul 31, 2026
1 check passed
@kblok
kblok deleted the task-based-race-remove-assumenevremits branch July 31, 2026 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant