Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>11.0.0-rc.3.3</Version>
<Version>11.0.0-rc.3.4</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
10 changes: 0 additions & 10 deletions src/middleware/BootstrapBlazor.Middleware/ConnectionSnapshot.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ internal async Task DispatchAsync(DispatchEntry<TEntry> entry, string? excludedC
Task callbackTask;
lock (_locker)
{
cancellationToken.ThrowIfCancellationRequested();
if (!_subscriptions.Contains(subscription))
{
continue;
Expand All @@ -59,7 +60,8 @@ internal async Task DispatchAsync(DispatchEntry<TEntry> entry, string? excludedC
callbackTask = subscription.Callback(entry);
}

await callbackTask;
await callbackTask.WaitAsync(cancellationToken);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Callbacks outlive canceled dispatches

When the token is canceled while a subscription callback is running, WaitAsync stops waiting, but subscription.Callback(entry) gets no token and keeps running after DispatchAsync returns canceled; retries run it concurrently, and later exceptions bypass subscriber-error logging, so callers see duplicate side effects and unlogged failures.

Pass cancellation into callbacks and keep their tasks observed until they finish.

Prompt for AI agents
In `src/middleware/BootstrapBlazor.Middleware/DefaultDispatchService.cs` at line 63:

**Callbacks outlive canceled dispatches**

When the token is canceled while a subscription callback is running, `WaitAsync` stops waiting, but `subscription.Callback(entry)` gets no token and keeps running after `DispatchAsync` returns canceled; retries run it concurrently, and later exceptions bypass subscriber-error logging, so callers see duplicate side effects and unlogged failures.

Pass cancellation into callbacks and keep their tasks observed until they finish.

cancellationToken.ThrowIfCancellationRequested();
Comment on lines +63 to +64

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Canceled dispatch is delivered twice

When the SignalR send completes, a local callback is still running, and cancellation leads the caller to retry, WaitAsync or the following cancellation check can make DispatchAsync return canceled after clients.SendAsync has already delivered the entry to the group. A caller that retries the canceled dispatch broadcasts the same entry again, so recipients process a duplicate.

Preserve an unambiguous success result once the broadcast has completed, or make retries idempotent using a dispatch identifier.

Prompt for AI agents
In `src/middleware/BootstrapBlazor.Middleware/DefaultDispatchService.cs` at lines 63-64:

**Canceled dispatch is delivered twice**

When the SignalR send completes, a local callback is still running, and cancellation leads the caller to retry, `WaitAsync` or the following cancellation check can make `DispatchAsync` return canceled after `clients.SendAsync` has already delivered the entry to the group. A caller that retries the canceled dispatch broadcasts the same entry again, so recipients process a duplicate.

Preserve an unambiguous success result once the broadcast has completed, or make retries idempotent using a dispatch identifier.

}
catch (Exception ex) when (!cancellationToken.IsCancellationRequested)
{
Expand Down
Loading