Skip to content

Commit de8c8d0

Browse files
committed
Add max wait time, respond to RequestAborted
1 parent a7b60be commit de8c8d0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/WebJobs.Script.WebHost/Diagnostics/HealthChecks/HealthCheckWaitMiddleware.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.HealthChecks
1111
{
1212
public sealed class HealthCheckWaitMiddleware(RequestDelegate next, IScriptHostManager manager)
1313
{
14+
private const int MaxWaitSeconds = 60;
1415
private readonly RequestDelegate _next = next ?? throw new ArgumentNullException(nameof(next));
1516
private readonly IScriptHostManager _manager = manager ?? throw new ArgumentNullException(nameof(manager));
1617

@@ -31,7 +32,8 @@ await context.Response.WriteAsJsonAsync(
3132
return;
3233
}
3334

34-
await _manager.DelayUntilHostReadyAsync(waitSeconds);
35+
waitSeconds = Math.Min(waitSeconds, MaxWaitSeconds);
36+
await _manager.DelayUntilHostReadyAsync(waitSeconds).WaitAsync(context.RequestAborted);
3537
}
3638

3739
await _next(context);

0 commit comments

Comments
 (0)