Skip to content

fix(status-pages): fast staged loading for public status pages - #504

Merged
fclairamb merged 23 commits into
mainfrom
fix/status-page-staged-loading
Oct 10, 2026
Merged

fclairamb merged 23 commits into
mainfrom
fix/status-page-staged-loading

Conversation

@fclairamb

@fclairamb fclairamb commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

The public status page was slow to show anything. On a 74-resource, 90-day page the resources appeared after 1.1 to 1.9 s in production (3 to 4 s under make dev), and the browser was frozen for most of that time. Three causes, all fixed here.

Results (production build, 74 resources, 90 days)

Before After
Resources on screen 1.1 to 1.9 s ~0.09 s
Page ready (bars, charts, updates) 1.1 to 1.9 s ~0.17 s (0.83 s on a cold server cache)
Main thread blocked ~1.8 s ~55 ms
Calls per 30 s refresh 1 big call 1 call

1. Load in stages

  • Stage 1 ?include=: sections, resources with current status, active incidents. First paint.
  • Stage 2 ?include=availability,responseTime: availability bars and response-time charts. If it fails, stage 1 stays on screen.
  • Stage 3 ?include=updates: recent updates, last 7 days. "Show older updates" asks for the full historyDays window with the new updatesDays param.
  • Stages 2 and 3 only fire once stage 1 succeeds, so a locked page shows the unlock form and nothing else. They start the moment stage 1's response arrives, not after React has rendered it.
  • Named pages (/s/{org}/{slug}), custom domains and the org's default page (/s/{org}/) all use it.
  • While stages 2 and 3 load, the bar, the chart, the row percentage and the header uptime pill keep their exact space, blank. Rows do not move when the data lands (CLS 0, desktop and mobile). A multi-region chart still adds its legend line, since stage 1 cannot know the regions.
  • Stage 1 no longer waits for the bundle: a small inline script in the shell starts it (then stages 2 and 3) while the JS downloads, and apiFetch takes those promises by exact URL. On a 100 ms round trip the page shows ~100 ms sooner (531 vs 630 ms, production build). The script is part of the built shell, so the CSP hashes allow it.
  • Once loaded, the page refreshes with one call, ?include=availability,responseTime,updates, instead of polling each stage.
  • Polls fetch with cache: "no-cache". The server's public, max-age=60, stale-while-revalidate=30 meant most 30 s polls were answered from the browser's disk cache, with data up to 90 s old. The header is unchanged, so a CDN still caches.

2. Slow SQLite query

The response-time seam query (AggregateResponseTimeBins) joined its p95/p50 CTEs back onto the bins, and SQLite planned one of those joins as a full scan per bin. It took 7 s and held the only connection, so every other query (page lookup, result inserts) queued behind it. Both percentiles are now computed in the same GROUP BY: identical rows, 0.26 s instead of 3.1 s on a copy of the dev database. Postgres is unchanged.

3. Rendering cost

  • The availability bar mounted one Radix tooltip per day segment (~6 600 on this page) and formatted every tooltip date up front, about 1 s of work. It now has one tooltip per bar, built for the hovered segment only.
  • All 74 response-time charts (recharts) drew at once, about 1 s more. They now mount when they come within 800 px of the viewport.
  • Each 30 s refresh re-rendered every row, bar segment and chart even when one number had changed. Sections, rows and the updates timeline are memoized, so a refresh only redraws the rows that changed.

API

  • New include token updates, and updatesDays (positive integer, bounded by historyDays, 400 otherwise).
  • No include still returns everything with the full historyDays window. The embed widget, the Atom feed and third parties are unchanged.
  • Documented in openapi.yaml and web/docs/docs/features/status-pages.md.

Also in this branch

Tests

  • Go: include=updates parsing, updatesDays validation, 7-day cap, full window without include, distinct memo keys. The seam query parity tests pass with the new SQL.
  • status0 unit tests: 156 pass.
  • status0 Playwright: 113 pass on a side-car server. New cases: delayed stage 2, failing stage 2, locked page, default page stages, row height kept when stage 2 lands, one call per refresh.
  • make lint-back, status0 lint and typecheck green. Postgres layer not run locally.

🤖 Generated with Claude Code

fclairamb and others added 12 commits October 8, 2026 07:28
Three specs from a self-hoster's report:
- 02: secret fields (SMTP password, JWT secret, inbox password) are
  dropped on first save; test mail ignores env overrides.
- 03: Discord webhook delivery was removed in #409 but the UI and docs
  still offer it. Bring it back as the no-bot fallback.
- 04: bot install uses a second redirect URI the public docs never list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add an updates include token (7-day default window, updatesDays to widen),
skip the timeline query when not requested, and load the status0 page as
include= then availability,responseTime then updates.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@fclairamb fclairamb changed the title feat(status-pages): load the public status page in stages fix(status-pages): load the public status page in stages Oct 10, 2026
@fclairamb
fclairamb enabled auto-merge (squash) October 10, 2026 17:16
@codecov

codecov Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.77%. Comparing base (638a4bb) to head (d247609).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #504      +/-   ##
==========================================
+ Coverage   82.67%   82.77%   +0.09%     
==========================================
  Files        1174     1174              
  Lines      121363   121369       +6     
==========================================
+ Hits       100341   100464     +123     
+ Misses      21015    20898     -117     
  Partials        7        7              
Files with missing lines Coverage Δ
server/internal/db/sqlite/response_time_bins.go 96.62% <100.00%> (-0.38%) ⬇️
server/internal/handlers/statuspages/handler.go 84.46% <100.00%> (+0.05%) ⬆️
server/internal/handlers/statuspages/memo.go 90.82% <100.00%> (+0.25%) ⬆️
server/internal/handlers/statuspages/service.go 91.67% <100.00%> (+1.03%) ⬆️
...rver/internal/handlers/statuspages/view_options.go 100.00% <100.00%> (ø)

... and 20 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fclairamb
fclairamb disabled auto-merge October 10, 2026 18:11
fclairamb and others added 6 commits October 10, 2026 20:23
The response-time seam query LEFT JOINed separate p95/p50 CTEs back onto
the bin aggregate. SQLite planned one join as a full scan of the
materialized ranked CTE per bin (1 754 bins x 58 k probes), so a cold
public status page spent 7 s in it and held the only connection,
stalling every other query. Computing both percentiles in the same
GROUP BY returns identical rows in 0.26 s.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
/s/{org}/ still made the single full call: only named pages were staged.
It now reads the same three stages from /status-pages/{org}.

Rendering stage 2 blocked the main thread for ~1.8 s in production
(~3 s under Vite) on a 74-resource, 90-day page:
- the availability bar mounted one Radix Tooltip per segment (~6 600)
  and formatted every tooltip date up front. It now has one controlled
  tooltip per bar, built only for the hovered segment.
- all 74 response-time charts drew at once. They now mount when they
  come within 800 px of the viewport, behind a same-height placeholder.

Production build: rows at ~90 ms (was 1.1 s), page ready at ~170 ms,
55 ms of long tasks (was 1.8 s).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
When the availability stage landed, every resource row grew by 162 px:
the bar skeleton was a flat 32 px block and the response-time chart had
no placeholder at all. On a narrow screen the hero uptime pill also
wrapped in late and pushed the page down by a line.

The bar and the chart now have skeletons built from the same boxes and
constants as the real components (the bar shares its axis line, with
the real labels; the chart its label, plot height, legend and strip).
The chart skeleton also stands in while a loaded chart waits to scroll
near the viewport. The per-row percentage and the hero pill keep their
place with a transparent copy of the same element.

Measured on a 74-resource page: 72 rows keep their height to the pixel
and CLS at stage 2 is 0 on desktop and mobile. A multi-region chart
still adds its 23 px legend, since stage 1 cannot know its regions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The bar, chart, row percentage and header pill placeholders keep the
exact boxes of what replaces them, but draw nothing (visibility hidden):
no grey block, no animation, no early labels. Rows still keep their
height when the availability stage lands.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Each stage query polled on its own, so every 30 s refresh cost three
requests. Once all three stages have answered, their merged result is
written into the cache of the full read
(?include=availability,responseTime,updates), and from then on that one
call is the only thing that polls. The seeded entry is fresh, so the
first poll waits a full interval. "Show older" refetches the same
single read with updatesDays, and a return visit that still finds a
full read in the cache skips the stages.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@fclairamb fclairamb changed the title fix(status-pages): load the public status page in stages fix(status-pages): fast staged loading for public status pages Oct 10, 2026
fclairamb and others added 4 commits October 11, 2026 00:06
From a 13-minute recording of the page:
- Every 30 s refresh re-rendered all 74 rows, their 6 660 bar segments
  and every mounted chart, even when one number had changed. Sections,
  rows and the updates timeline are now memoized; refreshes keep
  unchanged objects (structural sharing), so only changed rows redraw.
  The incident map they receive is memoized for the same reason.
- Stages 2 and 3 started only after React had rendered stage 1 (35 ms
  in production, ~250 ms under Vite). They are now prefetched the
  moment stage 1's response arrives. Replaying the recorded responses
  with their recorded server times, availability shows at ~1.03 s
  instead of ~1.45 s.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Public status-page responses carry public, max-age=60,
stale-while-revalidate=30 so a CDN can absorb an incident spike. The
browser obeys it too: the page polls every 30 s, and most polls were
answered from the disk cache, showing data up to 90 s old.

apiFetch now fetches with cache: "no-cache", so every poll reaches the
server. The header is unchanged: a CDN in front still caches, and the
server's 15 s memo absorbs repeated reads.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…dle boots

The stage-1 read (?include=) only left once the 300 KB bundle had loaded
and React had booted, while the read itself takes ~20 ms on the server.
A small inline script in the shell now starts it while the bundle
downloads, and on success stages 2 and 3, in the same order as
useStagedPublicStatusPage. It reads the page from the path, or from the
sp-page meta tag on a custom domain, and leaves TV routes alone.
apiFetch takes these promises once, by exact URL, instead of sending the
same request again. The script is part of the built shell, so the
server's CSP hashes allow it like the theme script.

Production build, median of 9: on a 100 ms round trip the read starts
at 235 ms instead of 514 ms and the page shows at 531 ms instead of
630 ms. On localhost the read starts at 8 ms instead of 56 ms, and the
page shows at the same time since the read costs 2 ms there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@fclairamb
fclairamb enabled auto-merge (squash) October 10, 2026 22:42
@fclairamb
fclairamb disabled auto-merge October 10, 2026 23:12
@fclairamb
fclairamb enabled auto-merge (squash) October 10, 2026 23:14
@fclairamb
fclairamb disabled auto-merge October 10, 2026 23:14
@fclairamb
fclairamb enabled auto-merge (squash) October 10, 2026 23:14
@fclairamb
fclairamb merged commit a269baa into main Oct 10, 2026
24 checks passed
@fclairamb
fclairamb deleted the fix/status-page-staged-loading branch October 10, 2026 23:39
fclairamb added a commit that referenced this pull request Oct 11, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.38.2](v0.38.1...v0.38.2)
(2026-10-11)


### Bug Fixes

* **dash0:** bug report screenshot shows the viewport, not the top of
the page ([#516](#516))
([114c547](114c547))
* **dash0:** center the auth card on mobile
([#490](#490))
([ca250f6](ca250f6))
* **dash0:** name a tunneled check's bastion even when it is not on the
page ([#512](#512))
([d1bb246](d1bb246))
* **deps:** update github.com/dop251/goja digest to 73dc7ed
([#503](#503))
([d2f7bfa](d2f7bfa))
* **deps:** update github.com/dop251/goja digest to a4bedf5
([#499](#499))
([638a4bb](638a4bb))
* **deps:** update go dependencies (non-major)
([#517](#517))
([9f6cbbc](9f6cbbc))
* **security:** address open code scanning and Dependabot alerts
([#514](#514))
([84dc69d](84dc69d))
* **status-pages:** fast staged loading for public status pages
([#504](#504))
([a269baa](a269baa))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant