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

@@ -24,8 +24,6 @@ namespace Microsoft.AspNetCore.Builder
/// </summary>
public static class SpaPrerenderingExtensions
{
private static TimeSpan BuildTimeout = 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
/// <summary>
/// Enables server-side prerendering middleware for a Single Page Application.
/// </summary>
@@ -71,6 +69,7 @@ namespace Microsoft.AspNetCore.Builder
var excludePathStrings = (options.ExcludeUrls ?? Array.Empty<string>())
.Select(url => new PathString(url))
.ToArray();
var buildTimeout = spaBuilder.Options.StartupTimeout;
applicationBuilder.Use(async (context, next) =>
{
@@ -93,9 +92,9 @@ namespace Microsoft.AspNetCore.Builder
// For better debuggability, create a per-request timeout that makes it clear if the
// prerendering builder took too long for this request, but without aborting the
// underlying build task so that subsequent requests could still work.
await buildOnDemandTask.WithTimeout(BuildTimeout,
await buildOnDemandTask.WithTimeout(buildTimeout,
$"The prerendering build process did not complete within the " +
$"timeout period of {BuildTimeout.Seconds} seconds. " +
$"timeout period of {buildTimeout.Seconds} seconds. " +
$"Check the log output for error information.");
}