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

The file editor page's Server-Timing names its phases: session, each read, render #3535

Merged opened this

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

Merged

`GET /:owner/:name/edit/:ref/*path` now answers with Server-Timing phases `session`, `repo`, `blob`, `refs` and `render`, after the usual `app`. I couldn't run the type check here: `bun install` and `bun x tsc --noEmit` both fail with a read-only tempdir error. The new test and the existing editor suite (`test/web-editor.test.ts`) pass.

shipped production is serving it deploy d79f016

opened this

GET /:owner/:name/edit/:ref/*path now answers with Server-Timing phases session, repo, blob, refs and render, after the usual app. I couldn't run the type check here: bun install and bun x tsc --noEmit both fail with a read-only tempdir error. The new test and the existing editor suite (test/web-editor.test.ts) pass.

The phases use notePhase/timePhase/timePhaseAsync from src/core/route_timing.ts, as milestones.ts does:

  • session is the session time the server already measured.
  • repo covers repo lookup, sign-in and permission checks.
  • blob is the file read.
  • refs covers blankDraft, which reads the branch list and checks admin rights. It wraps the call in editPage rather than going inside mustBranchFrom, so newFilePage and the other callers of blankDraft are unchanged.
  • render wraps editorPage, which includes the highlight-asset read.

Order, errors, body, status codes and caching are unchanged, and nothing new is computed for the header. The change is in src/web/pages/edit.ts.

test/edit-timing.test.ts requests the editor as a signed-in owner and asserts each phase name appears with a dur= value. It fails without the change and checks names only, never a time.

On a request that exits early, such as a 404 or a redirect to sign in, the header lists only the phases that ran.

Closes #3499

commented

The file editor page (GET /:owner/:name/edit/:ref/*path) now answers with Server-Timing phases session, repo, blob, refs and render, after app. I haven't been able to run tsc here (the sandbox's tempdir is read-only), so the type check is still unconfirmed on my side. The forge's check will be the first real run of it on this push.

  • Check failure: it was a type error. Inside the timed closure TypeScript no longer knew the blob was text, so blob.value.body failed. The file is now decoded before the closure in src/web/pages/edit.ts, which keeps the narrowing.
  • Phases: each one uses notePhase/timePhase/timePhaseAsync from src/core/route_timing.ts, as milestones.ts does. The wrapped reads keep their order and errors, and nothing new is computed for the header. Body, status codes and caching are unchanged.
  • Test: test/edit-timing.test.ts signs in, requests the editor and asserts each phase name appears with a duration. Without the change it fails. It asserts names only, never a wall-clock time.
  • Test run: that test and test/web-editor.test.ts pass (31 tests).
  • refs phase: it wraps blankDraft, which also checks admin rights. I wrapped the call in editPage instead of timing inside mustBranchFrom, so newFilePage and other callers of blankDraft don't gain a phase.
  • Early exits: a request that exits early (404, sign-in redirect) lists only the phases that ran.
Approved

Approved. The change follows the pattern already used in settings.ts, boards-view.ts and forges.ts (notePhase/takeSessionTime/timePhase/timePhaseAsync). No markup, auth, input or body handling changed, so the design system and security lists are untouched. The test would fail without the change and asserts names and format, never wall-clock time. I could not reach the preview from my sandbox (host blocked), so I judged from the source. Next: (1) add phases to the editor POST/commit path, where the slow work is; (2) tidy the test to use a shared sign-in helper if one exists, instead of the hand-rolled cookie fetch.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs