mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
Consider React dev server ready when it starts listening, not when (and if) it compiles successfully
This commit is contained in:
@@ -66,13 +66,16 @@ namespace Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer
|
|||||||
sourcePath, npmScriptName, null, envVars);
|
sourcePath, npmScriptName, null, envVars);
|
||||||
npmScriptRunner.AttachToLogger(logger);
|
npmScriptRunner.AttachToLogger(logger);
|
||||||
|
|
||||||
Match openBrowserLine;
|
|
||||||
using (var stdErrReader = new EventedStreamStringReader(npmScriptRunner.StdErr))
|
using (var stdErrReader = new EventedStreamStringReader(npmScriptRunner.StdErr))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
openBrowserLine = await npmScriptRunner.StdOut.WaitForMatch(
|
// Although the React dev server may eventually tell us the URL it's listening on,
|
||||||
new Regex("Local:\\s*(http\\S+)", RegexOptions.None, RegexMatchTimeout),
|
// 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),
|
||||||
StartupTimeout);
|
StartupTimeout);
|
||||||
}
|
}
|
||||||
catch (EndOfStreamException ex)
|
catch (EndOfStreamException ex)
|
||||||
@@ -91,8 +94,7 @@ namespace Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var uri = new Uri(openBrowserLine.Groups[1].Value);
|
return portNumber;
|
||||||
return uri.Port;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user