| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a98c145 commit 814441c
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,7 +20,6 @@ internal static class AngularCliMiddleware | |||
| 20 | 20 | { | |
| 21 | 21 | private const string LogCategoryName = "Microsoft.AspNetCore.SpaServices"; | |
| 22 | 22 | private static TimeSpan RegexMatchTimeout = TimeSpan.FromSeconds(5); // This is a development-time only feature, so a very long timeout is fine | |
| 23 | - 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 | ||
| 24 | 23 | ||
| 25 | 24 | public static void Attach( | |
| 26 | 25 | ISpaBuilder spaBuilder, | |
@@ -54,9 +53,10 @@ public static void Attach( | |||
| 54 | 53 | { | |
| 55 | 54 | // On each request, we create a separate startup task with its own timeout. That way, even if | |
| 56 | 55 | // the first request times out, subsequent requests could still work. | |
| 57 | - return targetUriTask.WithTimeout(StartupTimeout, | ||
| 56 | + var timeout = spaBuilder.Options.StartupTimeout; | ||
| 57 | + return targetUriTask.WithTimeout(timeout, | ||
| 58 | 58 | $"The Angular CLI process did not start listening for requests " + | |
| 59 | - $"within the timeout period of {StartupTimeout.Seconds} seconds. " + | ||
| 59 | + $"within the timeout period of {timeout.Seconds} seconds. " + | ||
| 60 | 60 | $"Check the log output for error information."); | |
| 61 | 61 | }); | |
| 62 | 62 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,8 +24,6 @@ namespace Microsoft.AspNetCore.Builder | |||
| 24 | 24 | /// </summary> | |
| 25 | 25 | public static class SpaPrerenderingExtensions | |
| 26 | 26 | { | |
| 27 | - 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 | ||
| 28 | - | ||
| 29 | 27 | /// <summary> | |
| 30 | 28 | /// Enables server-side prerendering middleware for a Single Page Application. | |
| 31 | 29 | /// </summary> | |
@@ -71,6 +69,7 @@ public static void UseSpaPrerendering( | |||
| 71 | 69 | var excludePathStrings = (options.ExcludeUrls ?? Array.Empty<string>()) | |
| 72 | 70 | .Select(url => new PathString(url)) | |
| 73 | 71 | .ToArray(); | |
| 72 | + var buildTimeout = spaBuilder.Options.StartupTimeout; | ||
| 74 | 73 | ||
| 75 | 74 | applicationBuilder.Use(async (context, next) => | |
| 76 | 75 | { | |
@@ -93,9 +92,9 @@ public static void UseSpaPrerendering( | |||
| 93 | 92 | // For better debuggability, create a per-request timeout that makes it clear if the | |
| 94 | 93 | // prerendering builder took too long for this request, but without aborting the | |
| 95 | 94 | // underlying build task so that subsequent requests could still work. | |
| 96 | - await buildOnDemandTask.WithTimeout(BuildTimeout, | ||
| 95 | + await buildOnDemandTask.WithTimeout(buildTimeout, | ||
| 97 | 96 | $"The prerendering build process did not complete within the " + | |
| 98 | - $"timeout period of {BuildTimeout.Seconds} seconds. " + | ||
| 97 | + $"timeout period of {buildTimeout.Seconds} seconds. " + | ||
| 99 | 98 | $"Check the log output for error information."); | |
| 100 | 99 | } | |
| 101 | 100 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,7 +19,6 @@ internal static class ReactDevelopmentServerMiddleware | |||
| 19 | 19 | { | |
| 20 | 20 | private const string LogCategoryName = "Microsoft.AspNetCore.SpaServices"; | |
| 21 | 21 | private static TimeSpan RegexMatchTimeout = TimeSpan.FromSeconds(5); // This is a development-time only feature, so a very long timeout is fine | |
| 22 | - 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 | ||
| 23 | 22 | ||
| 24 | 23 | public static void Attach( | |
| 25 | 24 | ISpaBuilder spaBuilder, | |
@@ -53,9 +52,10 @@ public static void Attach( | |||
| 53 | 52 | { | |
| 54 | 53 | // On each request, we create a separate startup task with its own timeout. That way, even if | |
| 55 | 54 | // the first request times out, subsequent requests could still work. | |
| 56 | - return targetUriTask.WithTimeout(StartupTimeout, | ||
| 55 | + var timeout = spaBuilder.Options.StartupTimeout; | ||
| 56 | + return targetUriTask.WithTimeout(timeout, | ||
| 57 | 57 | $"The create-react-app server did not start listening for requests " + | |
| 58 | - $"within the timeout period of {StartupTimeout.Seconds} seconds. " + | ||
| 58 | + $"within the timeout period of {timeout.Seconds} seconds. " + | ||
| 59 | 59 | $"Check the log output for error information."); | |
| 60 | 60 | }); | |
| 61 | 61 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -67,5 +67,11 @@ public PathString DefaultPage | |||
| 67 | 67 | /// development. The directory may not exist in published applications. | |
| 68 | 68 | /// </summary> | |
| 69 | 69 | public string SourcePath { get; set; } | |
| 70 | + | ||
| 71 | + /// <summary> | ||
| 72 | + /// Gets or sets the maximum duration that a request will wait for the SPA | ||
| 73 | + /// to become ready to serve to the client. | ||
| 74 | + /// </summary> | ||
| 75 | + public TimeSpan StartupTimeout { get; set; } = TimeSpan.FromSeconds(50); | ||
| 70 | 76 | } | |
| 71 | 77 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments