[Dashboard] FluentMenu null JS object reference intermittently terminates Blazor circuit in 13.5.2
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
### Is there an existing issue for this?
I searched the existing issues. This resembles #12356, which was considered fixed in 13.1, but this occurred on stable 13.5.2. The earlier stack failed in `FluentMenu.DisposeAsync`; this failure is in `FluentMenu.OnAfterRenderAsync`.
### Describe the bug
While using the resource command menu in the Aspire dashboard, the dashboard intermittently terminated its Blazor circuit because `FluentMenu.OnAfterRenderAsync` attempted to use a null JS object reference.
Refreshing the dashboard recovered it, and the issue has not reproduced consistently.
The resource command used `PromptConfirmationAsync`:
```csharp
server.WithCommand(
name: "reset-weather-fixture",
displayName: "Reset weather fixture",
executeCommand: async context =>
{
var interaction =
context.Services.GetRequiredService();
if (interaction.IsAvailable)
{
var confirmation = await interaction.PromptConfirmationAsync(
title: "Reset weather fixture?",
message: "This deletes the stored fixture.",
options: new MessageBoxInteractionOptions
{
Intent = MessageIntent.Confirmation
},
cancellationToken: context.CancellationToken);
if (confirmation.Canceled || !confirmation.Data)
{
return CommandResults.Canceled();
}
}
// Execute command...
return CommandResults.Success();
});
```
The command itself is probably not the direct cause. Logs show a noninteractive invocation completed successfully at `07:22:07`, while the dashboard circuit failed at `07:22:30`.
### Expected behavior
Opening and interacting with resource command menus should not terminate the dashboard circuit. A failed menu initialization should be handled without disconnecting the dashboard.
### Steps to reproduce
1. Run an AppHost containing a resource command that uses `PromptConfirmationAsync`.
2. Open the Aspire dashboard.
3. Open the resource command menu and invoke or interact with the command.
4. Observe that, intermittently, the dashboard disconnects.
5. Refresh the page to recover.
I have only observed this once so far.
### Exceptions (if any)
```text
System.ArgumentNullException: Value cannot be null.
(Parameter 'jsObjectReference')
at System.ArgumentNullException.Throw(String paramName)
at Microsoft.JSInterop.JSObjectReferenceExtensions.InvokeVoidAsync(
IJSObjectReference jsObjectReference,
String identifier,
Object[] args)
at Microsoft.FluentUI.AspNetCore.Components.FluentMenu.OnAfterRenderAsync(
Boolean firstRender)
```
This was followed by:
```text
Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost:
Unhandled exception in circuit.
Microsoft.JSInterop.JSDisconnectedException:
JavaScript interop calls cannot be issued at this time.
This is because the circuit has disconnected and is being disposed.
```
### .NET Version info
- Aspire CLI/AppHost: `13.5.2+a22cec24d76e764b3681977e314ab4a0aeed0240`
- .NET SDK: `10.0.204`
- OS: Windows ARM64
- Aspire CLI installed through WinGet
### Anything else?
Related issue: #12356
The dashboard's hidden resource logs contained the authoritative exception. Application telemetry contained no corresponding application error.
Contributor guide
Research direction
Trace the dashboard resource command menu lifecycle around FluentMenu.OnAfterRenderAsync and its JavaScript interop path, using the supplied reproduction, exception, and related issue #12356. Confirm the intermittent null-reference failure, then verify that opening and interacting with resource command menus no longer terminates the Blazor circuit and that the command flow still completes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100