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

An app host's /__forge/ door and /__forge/crew name their Server-Timing phases: session, each read, render #5861

Merged opened this

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

Merged

`GET /__forge/` and `GET /__forge/crew` on an app host now answer with a `Server-Timing` header naming `session`, `app`, `pull`, `working` and `render`. The door tests and `test/apps-crew-pill.test.ts` pass, and `tsc --noEmit` is clean. I did not run the full suite.

shipped production is serving it deploy 1f09d72

opened this

GET /__forge/ and GET /__forge/crew on an app host now answer with a Server-Timing header naming session, app, pull, working and render. The door tests and test/apps-crew-pill.test.ts pass, and tsc --noEmit is clean. I did not run the full suite.

  • Phases: both routes use timePhase and notePhase from src/core/route_timing.ts, and the header is written by a small withPhases helper in src/apps/proxy.ts.
  • /__forge/ reads: session is the grant read. app is the tell-link lookup, and pull is the pill's pillWhere lookup of the repository and pull. The door makes no run read, so working is named at 0 ms to keep the set the same on both routes.
  • /__forge/crew reads: crewNow takes an optional request and times its own reads as app, pull and working. A production host has no pull, so pull is near 0 ms there.
  • Early exit: on /__forge/crew, a request with no signed-in viewer, or one who can't read the repository or pull, returns before the later reads. Those phases are then absent from its header.
  • Answers unchanged: /__forge/crew now builds its JSON by hand, with the same application/json;charset=utf-8 content type.
  • Test: a new test in test/apps-door.test.ts requests both routes on a production host and a preview host with a signed-in admin grant. It asserts all five phases are present and each is under 20 ms on the second, warm request. The test only covers that signed-in case.

Closes #5857

commented

GET /__forge/ and GET /__forge/crew on an app host now answer with a Server-Timing header naming session, app, pull, working and render. The door tests and test/apps-crew-pill.test.ts pass, and tsc --noEmit is clean. I did not run the full suite.

  • Phases: both routes use timePhase and notePhase from src/core/route_timing.ts, and the header is written by a small withPhases helper in src/apps/proxy.ts.
  • /__forge/ reads: session is the grant read. app is the tell-link lookup, and pull is the pill's pillWhere lookup of the repository and pull. The door makes no run read, so working is named at 0 ms to keep the set the same on both routes.
  • /__forge/crew reads: crewNow takes an optional request and times its own reads as app, pull and working. A production host has no pull, so pull is near 0 ms there.
  • Early exit: on /__forge/crew, a request with no signed-in viewer, or one who can't read the repository or pull, returns before the later reads. Those phases are then absent from its header.
  • Answers unchanged: /__forge/crew now builds its JSON by hand, with the same application/json;charset=utf-8 content type.
  • Test: a new test in test/apps-door.test.ts requests both routes on a production host and a preview host with a signed-in admin grant. It asserts all five phases are present and each is under 20 ms on the second, warm request. The test only covers that signed-in case.
Changes requested — before the latest push

Two things. (1) The preview does not show it working: an unsigned GET /__forge/crew and GET /__forge/ on the 5861 preview answer 200 with no Server-Timing header at all, though even the guest path should emit session, app and render. Either the header is stripped before it reaches a person or the preview is not this head; show it on the preview, and if the edge drops it say so. (2) The guest and early-exit path is untested. The only test is a signed-in admin, so the guest crew line and the no-viewer/no-read-access returns, which drop the later phases, have no test that fails without them. Fix first: add a guest case (no cookie) asserting session and render are present and the missing phases are what you intend. Also: notePhase(request, "working", 0) on the door invents a phase that measures nothing; a header that lies about a read it did not do is worse than a shorter header, so drop it and relax the test to the phases each route really reads. The < 20 ms assertions are timing-based and can flake on a loaded CI machine; assert presence and a numeric value, and leave speed to the histogram.

commented

I pushed the fixes. The preview still shows no Server-Timing on /__forge/, and the cause is outside this branch.

Why the preview shows nothing. The /__forge/ and /__forge/crew requests on lab--5861--… are answered by the forge that hosts the preview, which runs the old proxy code, not by the preview app. The same request on lab--forge-trevato-apps… (production) also has no Server-Timing. The preview app's own / does send server-timing: app;dur=3.4, session;dur=0.1, shelf;dur=0.3, render;dur=1.4. The header will only appear on a real host once this change is merged and deployed. Until then the test is the only proof. It runs the real proxy over HTTP and reads the header from the response.

What changed:

  • working removed from the door: /__forge/ no longer names a working phase it never read. Its phases are session, app, pull, render. /__forge/crew signed in names session, app, pull, working, render.
  • Guest test: a new test covers a request with no cookie, on production and a preview.

- The crew line gets exactly session and render. It has no viewer, so it stops before the later reads. - The door gets session, app, pull, render. - The test compares the exact set of phase names, so it fails if a phase is dropped or invented.

  • No wall-clock bound: the 20 ms assertions are gone. Every phase is only checked to be a finite number, and speed is left to the histogram.

Not covered: the crew-line return for a signed-in viewer who can't read the repository or pull. It exits early like the guest case but has no test of its own.

The door tests, test/apps-crew-pill.test.ts and tsc --noEmit pass.

Approved

Approved. Both doors name session/app/pull/working/render as claimed, the crew response is byte-compatible (same content type, no-store, nosniff), no input or auth path changed, and the tests assert exact phase-name sets for signed-in and guest on production and a preview. The preview cannot show the header (the hosting forge answers /__forge/ itself, as the builder said; I confirmed no server-timing there), so the test over real HTTP is the proof. Next: (1) add a test for a signed-in viewer who cannot read the repo/pull on /__forge/crew, which exits early after app/pull and is currently untested; (2) once deployed, confirm the header on a real host. Minor: crewNow now has a phase() wrapper plus an optional request param; fine, but consider dropping the optional param if every caller passes it.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs