dotnet / dotnet/aspnetcore

SPA startup error - TimeoutException: The create-react-app server did not start listening for requests within the timeout period of 120 seconds.

Open
#55,073 1 comment 0 reactions 0 assignees View on GitHub
area-mvc
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

Getting this error when starting up the application for development,
![image](https://github.com/dotnet/aspnetcore/assets/4073740/492c2fac-e0d3-4f62-93a4-92f3210c116e)
Framework version: .Net 8
React typescript 18.2.0
Node 18.20.0
Using Microsoft.AspNetCore.SpaServices.Extensions for configuring SPA.

Using following code to register SPA,

```
builder.Services.AddSpaStaticFiles(configuration =>
{
configuration.RootPath = "WebClient/dist";
});
.....
app.UseSpa(spa =>
{
spa.Options.SourcePath = "WebClient";
// Only in local development use npm start. Not in test/production.
if (environment.IsDevelopment())
{
spa.Options.StartupTimeout = TimeSpan.FromSeconds(300);
spa.UseReactDevelopmentServer(npmScript: "dev");
}
});
```

I have increased the timeout limit but still same error. We have the same set up in a .Net 6 app and it works fine but since .Net 8 there seems to be some changes in the proxy implementation which is causing this issue. I can see ReactDevelopmentServerMiddleware is executing the command and browse to front end from its url.

### Expected Behavior

_No response_

### Steps To Reproduce

_No response_

### Exceptions (if any)

_No response_

### .NET Version

8.0.204

### Anything else?

VS Version 17.9.6

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.