JavaScript installer ignores parent WithExplicitStart()
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Describe the bug
### Issue
`WithNpm(install: true)` creates a separate `JavaScriptInstallerResource`, and the application waits for that installer to complete before starting.
The current behavior appears to ignore the `WithExplicitStart()` annotation on the parent JavaScript application:
* `WithNpm(install: true)` creates the installer resource and causes it to auto-start.
* `WithNpm(install: false)` marks the installer itself as explicit-start.
* The parent's `WithExplicitStart()` annotation is not propagated to, or considered by, the generated `JavaScriptInstallerResource`.
As a result, an application configured with `WithExplicitStart()` can still cause its `app-installer` resource to start automatically during AppHost startup, even though the JavaScript application itself is deferred.
### Expected Behavior
When the parent JavaScript application is configured with `WithExplicitStart()`, its associated `JavaScriptInstallerResource` should respect the same explicit-start semantics and **not start automatically**.
In other words, an explicitly started JavaScript application should not implicitly start its npm installer during AppHost startup.
This appears to conflict with the documented semantics of `WithExplicitStart()`, which indicate that the resource should not be started automatically.
### Steps To Reproduce
### Minimal reproduction
```csharp
var builder = DistributedApplication.CreateBuilder(args);
var app = builder.AddJavaScriptApp("app", "../frontend")
.WithNpm(install: true)
.WithExplicitStart();
builder.Build().Run();
```
With this configuration, the expected behavior is:
1. `app` is marked as `ExplicitStart`.
2. `app` does not start automatically when the AppHost starts.
3. The associated npm installer should likewise not start automatically.
However, the actual behavior is:
```text
AppHost starts
│
├── app [ExplicitStart → not started]
│
└── app-installer [starts automatically]
│
└── npm install
```
The `app-installer` is therefore started during AppHost startup even though the parent `app` resource has been configured with `WithExplicitStart()`.
For comparison, removing `WithExplicitStart()` results in both the application and its installer starting automatically:
```csharp
var app = builder.AddJavaScriptApp("app", "../frontend")
.WithNpm(install: true);
```
The issue is that the generated `JavaScriptInstallerResource` appears to have its own startup behavior that does not take the parent's `WithExplicitStart()` state into account.
### Exceptions (if any)
_No response_
### Aspire doctor output
```plain
```
### Anything else?
_No response_
Contributor guide
Research direction
Start from the AddJavaScriptApp, WithNpm, and WithExplicitStart entry points and trace how the generated JavaScriptInstallerResource receives its startup behavior. Use the minimal reproduction to verify the current lifecycle, then add or update a regression test showing that both app and app-installer remain deferred; done means the installer does not start automatically when the parent is explicitly started.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, javascript
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100