Cap live SSE stream lifetime and fix response-time telemetry - #1805
Merged
David Pine (IEvangelist) merged 2 commits intoOct 1, 2026
Merged
David Pine (IEvangelist) merged 2 commits into
David Pine (IEvangelist) merged 2 commits into
Conversation
- End each /api/live/stream after a jittered Live:StreamMaxLifetimeSeconds (default 600s) - Close the stream in tabs hidden for 60s; reconnect when visible - Add jitter to the client reconnect backoff - Exclude /api/live/stream from ASP.NET Core request traces - Honor Front Door's X-Azure-ClientIP as the client IP - Update Live README and appsettings Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Blocked response writes can exceed the lifetime cap, and the randomized lifetime test is nondeterministically flaky.
Review effort: Balanced
Findings: 2
Open (2)
What changed in this PR
Caps SSE lifetimes, improves reconnect behavior, filters stream telemetry, and restores Front Door client IPs.
Changes:
- Adds server-side SSE lifetime limits and telemetry filtering.
- Closes hidden-tab streams and jitters reconnect delays.
- Adds configuration, documentation, and tests.
| File | Description |
|---|---|
tests/StaticHost.Tests/Live/LiveStreamTests.cs |
Tests stream lifetime limits. |
src/statichost/StaticHost/Program.cs |
Enables forwarded client IP handling. |
src/statichost/StaticHost/Live/README.md |
Documents stream lifecycle behavior. |
src/statichost/StaticHost/Live/LiveStatusOptions.cs |
Defines maximum stream lifetime. |
src/statichost/StaticHost/Live/LiveEndpoints.cs |
Applies jittered stream cancellation. |
src/statichost/StaticHost/Extensions.cs |
Configures forwarding and telemetry filtering. |
src/statichost/StaticHost/appsettings.json |
Sets the default lifetime. |
src/frontend/tests/unit/live-status.vitest.test.ts |
Tests reconnect and visibility behavior. |
src/frontend/src/components/live-status.ts |
Adds reconnect jitter and hidden-tab cleanup. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
Frontend HTML artifact readyThe latest frontend build uploaded the This comment updates automatically when a new frontend build artifact is uploaded. |
Eric Erhardt (eerhardt)
approved these changes
Oct 1, 2026
David Pine (IEvangelist)
deleted the
ievangelist-statichost-429-response-time-analysis
branch
October 1, 2026 19:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
After the release/13.6 deploy, App Service response time showed a sawtooth: the maximum grew about one second per second until restart (around 369,000 s) and the mean was about 79 s. The likely cause is
/api/live/stream. The SSE stream had no lifetime cap, a 15 s heartbeat kept it open indefinitely, and hidden tabs never closed it. Each stream was recorded as a single request lasting hours or days, so the chart probably reflects stream lifetimes, not slow page serving.Changes:
Live:StreamMaxLifetimeSeconds(default 600 s), and the client reconnects./api/live/streamis excluded from ASP.NET Core request traces.X-Azure-ClientIP(ForwardLimit = 1) as the client IP. Before this,RemoteIpAddresswas always the Front Door edge address, so any future per-IP rate limit would put every user in one bucket. Callers that bypass Front Door can spoof this header, so use the value for telemetry only.appsettings.jsonupdated.HTTP 429 posture: the app has no rate limiter, and this repo's infrastructure code defines no Front Door WAF policy, so 429s can't originate here. Twitch/YouTube upstream calls are leader-leased through Redis, which keeps quota risk low.
Third-party links and affiliations
None
Validation
dotnet test tests\StaticHost.Tests --filter "FullyQualifiedName!~Integration": passed (307). Includes the newStreamSse_EndsWithinJitteredMaxLifetimetest.pnpm exec vitest run tests/unit/live-status.vitest.test.ts: passed (12). New tests cover jitter, hidden-tab close, and reconnect on visible.Not yet confirmed: whether the original chart is the App Insights or the App Service metric. After deploy, check with: