Allow configuration of SPA startup timeout. Part of #1447

This commit is contained in:
Steve Sanderson
2018-01-02 14:13:47 +00:00
parent a98c1459b5
commit 814441c933
4 changed files with 15 additions and 10 deletions

View File

@@ -19,7 +19,6 @@ namespace Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer
{
private const string LogCategoryName = "Microsoft.AspNetCore.SpaServices";
private static TimeSpan RegexMatchTimeout = TimeSpan.FromSeconds(5); // This is a development-time only feature, so a very long timeout is fine
private static TimeSpan StartupTimeout = TimeSpan.FromSeconds(50); // Note that the HTTP request itself by default times out after 60s, so you only get useful error information if this is shorter
public static void Attach(
ISpaBuilder spaBuilder,
@@ -53,9 +52,10 @@ namespace Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer
{
// On each request, we create a separate startup task with its own timeout. That way, even if
// the first request times out, subsequent requests could still work.
return targetUriTask.WithTimeout(StartupTimeout,
var timeout = spaBuilder.Options.StartupTimeout;
return targetUriTask.WithTimeout(timeout,
$"The create-react-app server did not start listening for requests " +
$"within the timeout period of {StartupTimeout.Seconds} seconds. " +
$"within the timeout period of {timeout.Seconds} seconds. " +
$"Check the log output for error information.");
});
}