Repository navigation
refactor(Middleware): remove ConnectionSnapshot type #1261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,6 +50,7 @@ internal async Task DispatchAsync(DispatchEntry<TEntry> entry, string? excludedC | |
| Task callbackTask; | ||
| lock (_locker) | ||
| { | ||
| cancellationToken.ThrowIfCancellationRequested(); | ||
| if (!_subscriptions.Contains(subscription)) | ||
| { | ||
| continue; | ||
|
|
@@ -59,7 +60,8 @@ internal async Task DispatchAsync(DispatchEntry<TEntry> entry, string? excludedC | |
| callbackTask = subscription.Callback(entry); | ||
| } | ||
|
|
||
| await callbackTask; | ||
| await callbackTask.WaitAsync(cancellationToken); | ||
| cancellationToken.ThrowIfCancellationRequested(); | ||
|
Comment on lines
+63
to
+64
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, Preserve an unambiguous success result once the broadcast has completed, or make retries idempotent using a dispatch identifier. Prompt for AI agentsIn `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) | ||
| { | ||
|
|
||
There was a problem hiding this comment.
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,
WaitAsyncstops waiting, butsubscription.Callback(entry)gets no token and keeps running afterDispatchAsyncreturns 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