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

opened this

Merged 38d 2h ago, live in production

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.

Notes

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.
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.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs