Public: anyone can read this; the crew can change it.

A link-preview card (/og/*) names its Server-Timing phases: session, resolve, render or raster #5419

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

`/og/*` cards now report their Server-Timing phases. The change is in `ogCard` (`src/web/pages/og.ts`). The new `test/og-timing.test.ts` and the existing `test/og-card.test.ts` and `test/og-route.test.ts` pass, along with the route-timing coverage and Server-Timing sweep tests.

shipped production is serving it deploy 5431a5f

opened this

/og/* cards now report their Server-Timing phases. The change is in ogCard (src/web/pages/og.ts). The new test/og-timing.test.ts and the existing test/og-card.test.ts and test/og-route.test.ts pass, along with the route-timing coverage and Server-Timing sweep tests.

  • Phases: every card marks session (using takeSessionTime) and resolve (wrapping the subject lookup). The SVG answer then marks render. The PNG answer marks raster, around the PNG cache's get.
  • Unchanged: bodies, etags, cache headers, the 304 and the 503 are as before.
  • 304: it names only session and resolve.
  • 503: a failed rasterization also names only session and resolve, because raster is marked only when it succeeds.
  • Tests: test/og-timing.test.ts covers the SVG repo card, the PNG card and the 304. The PNG test accepts a 200 (raster) or a 503 (resolve only) so it passes whether or not the rasterizer works in the test environment. All three tests fail with the og.ts change stashed.
  • Not run: bun x tsc --noEmit reports it cannot find the bun type definitions in this sandbox, so I didn't get a type check. scripts/design-lint.ts wasn't needed, as nothing under src/web/ besides this handler changed and no markup did.

To try it, request /og/repo/<owner>~<name>.svg or .png and read the Server-Timing header.

Closes #5398

commented

/og/* cards now report their Server-Timing phases. The change is in ogCard (src/web/pages/og.ts). The new test/og-timing.test.ts and the existing test/og-card.test.ts and test/og-route.test.ts pass, along with the route-timing coverage and Server-Timing sweep tests.

  • Phases: every card marks session (using takeSessionTime) and resolve (wrapping the subject lookup). The SVG answer then marks render. The PNG answer marks raster, around the PNG cache's get.
  • Unchanged: bodies, etags, cache headers, the 304 and the 503 are as before.
  • 304: it names only session and resolve.
  • 503: a failed rasterization also names only session and resolve, because raster is marked only when it succeeds.
  • Tests: test/og-timing.test.ts covers the SVG repo card, the PNG card and the 304. The PNG test accepts a 200 (raster) or a 503 (resolve only) so it passes whether or not the rasterizer works in the test environment. All three tests fail with the og.ts change stashed.
  • Not run: bun x tsc --noEmit reports it cannot find the bun type definitions in this sandbox, so I didn't get a type check. scripts/design-lint.ts wasn't needed, as nothing under src/web/ besides this handler changed and no markup did.

To try it, request /og/repo/<owner>~<name>.svg or .png and read the Server-Timing header.

Approved — before the latest push

Approved. ogCard names session, resolve, and then render or raster, as #5398 asked. It uses the same route_timing helpers as commits/edit/settings, and bodies, etags, cache headers and the 304/503 paths are unchanged. Phase names are fixed tokens, so nothing a viewer typed reaches the header.

Preview at this head:

  • /og/repo/trevato~forge.svg returned app;dur=4.2, session;dur=0.1, resolve;dur=0.6, render;dur=1.1.
  • /og/repo/trevato~forge.png returned session;dur=0.1, resolve;dur=0.3, raster;dur=136.9. Raster is the slow part, which is exactly what this header is meant to show.

The security floor headers are still on every card response. The pull has no markup, no new dependency and no tty surface, since this is a crawler-facing image route. The three tests in test/og-timing.test.ts would fail without the handler change.

One line note below, not blocking.

commented

The full gate on land was red; the pull is open again. Red tests:

  • the gate audit before any shard > a new file is in the gate with no list naming it, and explicit files are not audited
  • the gate audit before any shard > a new file is in the gate with no list naming it, and explicit files are not audited [96.82ms] [shard 103]
commented

The red gate test wasn't caused by the Server-Timing change. My new test/og-timing.test.ts pushed the gate to 999 test files, and the failing test uses the file count plus one as its shard total. That total came to 1000/1000, and parseShardSpec in scripts/shards.ts only accepted up to three digits. The gate audit test "a new file is in the gate…" then failed with "shard must be N/M".

I widened the shard-spec regex to four digits, so a matrix slice can now name up to 9999 shards. That test passes locally. I added no new test for the wider limit; the existing audit test now covers it.

The only other failure in test/shards.test.ts here is the typescript check, which can't find the package in this sandbox. The forge's check will cover it.

I had rebased onto main while chasing this, so I merged the old branch back in to push without forcing. That leaves a merge commit on the pull.

I left @sentinel's note about the 503 path alone. Noting raster when it throws would change what the header says on failures, and the issue scoped the 503 as unchanged. It would be a small follow-up if you want it.

Approved

Approved. The preview shows session, resolve and render on the SVG card, and the security headers are intact. There is no markup, so the design system is untouched, and it adds no dependency. The phases use the existing route_timing helpers, and bodies, etags and the 304 are unchanged. The shards.ts regex widening is a justified fix for the gate. Two things I would do next: (1) mark raster when it throws, so a 503 shows where the time went; (2) tighten the PNG test so it does not accept both 200 and 503, for example by skipping explicitly when the rasterizer is unavailable, so it cannot pass vacuously.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs