-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Core 3.1, UseReactDevelopmentServer middleware & Performance #19052
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@yahorsi thanks for contacting us. We believe this is a duplicate of a similar issue. It has to do with node just listening in IPv4 by default. I believe you can change the redirect middleware to use |
Thank you for reply! Few things to clarify
Thanks |
This does not work, as, I understand port and host is specified by ReactDevelopmentServer.
That is corresponding code... BTW, why are you thinking moving node to 127.0.0.1 from localhost will solve the issue? private static async Task<int> StartCreateReactAppServerAsync(
string sourcePath, string npmScriptName, ILogger logger)
{
var portNumber = TcpPortFinder.FindAvailablePort();
logger.LogInformation($"Starting create-react-app server on port {portNumber}...");
var envVars = new Dictionary<string, string>
{
{ "PORT", portNumber.ToString() },
{ "BROWSER", "none" }, // We don't want create-react-app to open its own extra browser window pointing to the internal dev server port
};
var npmScriptRunner = new NpmScriptRunner(
sourcePath, npmScriptName, null, envVars);
npmScriptRunner.AttachToLogger(logger);
using (var stdErrReader = new EventedStreamStringReader(npmScriptRunner.StdErr))
{
try
{
// Although the React dev server may eventually tell us the URL it's listening on,
// it doesn't do so until it's finished compiling, and even then only if there were
// no compiler warnings. So instead of waiting for that, consider it ready as soon
// as it starts listening for requests.
await npmScriptRunner.StdOut.WaitForMatch(
new Regex("Starting the development server", RegexOptions.None, RegexMatchTimeout));
}
catch (EndOfStreamException ex)
{
throw new InvalidOperationException(
$"The NPM script '{npmScriptName}' exited without indicating that the " +
$"create-react-app server was listening for requests. The error output was: " +
$"{stdErrReader.ReadAsString()}", ex);
}
}
return portNumber;
} |
See #18062 for the discussion. |
We've moved this issue to the Backlog milestone. This means that it is not going to happen for the coming release. We will reassess the backlog following the current release and consider this item at that time. However, keep in mind that there are many other high priority features with which it will be competing for resources. |
I am currently writing a book for Azure and some of the samples are based on React and ASP.NET. I am running into this issue, #19052, all the time. Performance is abysmal. Sometimes its instantaneous, others it takes a long time to startup. The standard ASP.NET React template does not include a good way to exclude the call to the UseReactDevelopmentServer. Instead, it relies on an environment check for env.IsDevelopment and if in development, it makes the call to UseReactDevelopmentServer. For containers, we would rather use 'npm run build', generate our React template, but still allow debugging of our ASP.NET supporting services. This would allow us just to deploy our static frontend and our dotnet application without deploying NodeJs to our container for development. The challenge is that the development environment is set in Visual Studio Code when debugging into a container, as it should. Then the call to UseReactDevelopmentServer happens which does not find npm and NodeJs and fails. It is also a spectacular failure too with an uncaught background exception that brings down the entire application. We would expect that this would fail silently. I have considered not using the ASP.NET React template at all because of these issues and going with a standard Create React App template and use backend set of APIs. For us, we still believe there is significant value with services that are deployed with and support our user interface directly. The right solution is to compile out the use of the UseReactDevelopmentServer in the container builds, but we cannot do so very easily. You would think that you could, but passing the needed conditionals on 'dotnet build' and 'dotnet publish' is voodoo. So my ask is the following:
|
For those experiencing this issue and looking for a temporary fix, you can set HOST=::1 in your .env file of your Create React App. This should cause node to listen on IPv6 loopback. |
This is a dupe of #22769. We recommend following the guidance offered there |
Uh oh!
There was an error while loading. Please reload this page.
Hi Guys,
We recently have started working on the new .NET Core 3.1.1 & React SPA.
In order to start, we have created the app from the template (.NET Core Web Application + React) and noticed that some request that gets proxied to the node takes longer than they should.
The only change in the template we made - we have disabled https redirection and open the local site using just HTTP. As you see on the screenshot, sometimes requests that's get proxied takes about the second and sometimes they are fast. NOTE: Press F5 several times
If we run the site using exactly the same command as used by the UseReactDevelopmentServer - npm start, that runs "rimraf ./build && react-scripts start" we will see following timings:
Things start working very very fast and that is really noticeable for the developers working on the frontend as frontend needs to reload on the change.
So, my wild guess is that there is something wrong happening in the middleware that is proxying calls to the node.
I have uploaded the app I was using here https://github.com/yahorsi/ReactDevServerMiddlewarePerf
PS1: I have also noticed that it seems when you stop C# app - Node is not stopped and so, after a while you have a LOT's of node instances running
PS2: Seems template needs to be updated as after the start it complains that npm update needed
PS3: Running in the release configuration does not solve the issue
The text was updated successfully, but these errors were encountered: