microsoft / microsoft/aspire

Using `InteractionSerivce` in `BeforeStart` deadlocks

Open
#11,371 1 comment 0 reactions 0 assignees View on GitHub
area-integrations
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 12h
Merged PRs (30d)
201

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

If you try to use the interaction service in `BeforeStart`, it will deadlock the app host, even if you guard the prompt with `interactionService.IsAvailable`.

### Expected Behavior

`interactionService.IsAvailable` should return false if the dashboard isn't running (such as in `BeforeStart`) (or has failed for any reason).

### Steps To Reproduce

```cs
builder.Eventing.Subscribe(async (evt, ct) =>
{
var interactionService = evt.Services.GetRequiredService();

if (!interactionService.IsAvailable)
{
return;
}

await interactionService.PromptMessageBoxAsync(
title: "👋🌍",
message: "Hello World",
options: new MessageBoxInteractionOptions
{
EnableMessageMarkdown = true,
Intent = MessageIntent.Error,
});
});
```

### Exceptions (if any)

_No response_

### .NET Version info

_No response_

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the BeforeStart event subscription and the IInteractionService implementation used by the dashboard; the payload does not name specific files or tests. Reproduce the example, then trace IsAvailable and the prompt call. Done means IsAvailable is false when the dashboard is unavailable, including during BeforeStart, and the app host does not deadlock.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.