Skip to content

fix: marshal dialog provider Add/Update onto sync context - #5301

Merged
Vincent Baaij (vnbaaij) merged 1 commit into
microsoft:archive-v4from
shanewas:fix/dialog-provider-task-run-race
Sep 18, 2026
Merged

Vincent Baaij (vnbaaij) merged 1 commit into
microsoft:archive-v4from
shanewas:fix/dialog-provider-task-run-race

Conversation

@shanewas

Copy link
Copy Markdown

Fixes #5300.

ShowDialogAsync / UpdateDialogAsync wrapped the References mutation in Task.Run, racing the UI-thread render enumeration and the close-path Remove whenever a dialog opened right after another closed. On Blazor Server this surfaces as ArgumentOutOfRangeException, a render NullReferenceException, or a dead circuit, at a low single-digit percent per cycle.

This runs both bodies through InvokeAsync instead, matching the sync ShowDialog path already in this file, so the Add / Update always lands on the renderer's sync context. No behavior change besides removing the race window. ComponentBase.InvokeAsync has no value-returning overload, so results are captured via locals.

Verified: Microsoft.FluentUI.AspNetCore.Components builds with 0 errors (net8.0 / net9.0 / net10.0).

@shanewas

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@shanewas
Shanewas Ahmed (shanewas) force-pushed the fix/dialog-provider-task-run-race branch from f726592 to 420fa2f Compare September 18, 2026 01:52
@vnbaaij
Vincent Baaij (vnbaaij) changed the base branch from main to archive-v4 September 18, 2026 03:47
@vnbaaij
Vincent Baaij (vnbaaij) changed the base branch from archive-v4 to main September 18, 2026 03:49

@vnbaaij Vincent Baaij (vnbaaij) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hi, Thanks for your contribution but 2 things:

  • We are moving into maintenance mode for v4. Final release of v5 is around the corner. That doesn't mean we can't merge this in but might take a bit longer for this to show up in a package
  • You must target the archive-v4branch for this change (since yesterday, was dev before)

ShowDialogAsync and UpdateDialogAsync wrapped the References mutation in Task.Run, racing the UI-thread render enumeration and close-path Remove whenever a dialog opened right after another closed. Run both bodies through InvokeAsync instead, matching the sync ShowDialog path. Fixes microsoft#5300.
@shanewas
Shanewas Ahmed (shanewas) force-pushed the fix/dialog-provider-task-run-race branch from 420fa2f to d45e5b8 Compare September 18, 2026 06:28
@shanewas
Shanewas Ahmed (shanewas) changed the base branch from main to archive-v4 September 18, 2026 06:28
@shanewas

Copy link
Copy Markdown
Author

Retargeted to archive-v4. Rebased onto 518038a (same 1-file hunk, commit re-signed). Local SDK predates the pinned Roslyn so the full build can't link here; verified zero new errors against pristine base. CI should give the full gate.

@vnbaaij
Vincent Baaij (vnbaaij) merged commit e224d98 into microsoft:archive-v4 Sep 18, 2026
3 of 4 checks passed
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.

fix: FluentDialogProvider ShowDialogAsync races: Task.Run mutates References off the sync context

2 participants