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

The API's contents read names its Server-Timing phases: session, git, render #4015

Merged opened this

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

Merged

The contents read's Server-Timing phases were already implemented on this branch. I merged the latest `main` (18 new commits) into it and pushed. I made no new code changes, so I can't say why the forge's check failed on the closed pull #3792.

shipped production is serving it deploy 4183511

opened this

The contents read's Server-Timing phases were already implemented on this branch. I merged the latest main (18 new commits) into it and pushed. I made no new code changes, so I can't say why the forge's check failed on the closed pull #3792.

  • Change: contentsHandler in src/http/api.ts names session, git and render in Server-Timing.

- git adds up the cat-file -t probe and the listTree or blobForRender read. - render covers encoding and JSON. - A 404 still names session (and git once the git read has run). The JSON bodies are unchanged.

  • Tests: test/api-contents-timing.test.ts checks the phase names for a directory and a file. It and test/api-pull-timing.test.ts pass after the merge (5 tests).
  • Not verified: bun x tsc --noEmit wouldn't run here, because bun couldn't write to its temp dir. The forge's check will run the type check.
  • Possible cause: src/http/api.ts imports from ../core/route_timing.ts twice, at lines 18 and 253. If the forge's type check rejects the duplicate, that is the likely cause. I left it alone because I couldn't confirm it.
  • Left out: I touched no other handler in api.ts.

To try it, request GET /api/v1/repos/:owner/:name/contents (a directory) or .../contents/<file> (a file). The Server-Timing header lists app, session, git and render.

🤖 Generated with Claude Code

Closes #3781

commented

The contents read's Server-Timing phases were already implemented on this branch. I merged the latest main (18 new commits) into it and pushed. I made no new code changes, so I can't say why the forge's check failed on the closed pull #3792.

  • Change: contentsHandler in src/http/api.ts names session, git and render in Server-Timing.

- git adds up the cat-file -t probe and the listTree or blobForRender read. - render covers encoding and JSON. - A 404 still names session (and git once the git read has run). The JSON bodies are unchanged.

  • Tests: test/api-contents-timing.test.ts checks the phase names for a directory and a file. It and test/api-pull-timing.test.ts pass after the merge (5 tests).
  • Not verified: bun x tsc --noEmit wouldn't run here, because bun couldn't write to its temp dir. The forge's check will run the type check.
  • Possible cause: src/http/api.ts imports from ../core/route_timing.ts twice, at lines 18 and 253. If the forge's type check rejects the duplicate, that is the likely cause. I left it alone because I couldn't confirm it.
  • Left out: I touched no other handler in api.ts.

To try it, request GET /api/v1/repos/:owner/:name/contents (a directory) or .../contents/<file> (a file). The Server-Timing header lists app, session, git and render.

🤖 Generated with Claude Code

Approved — before the latest push

Read every changed line. Security: nothing new comes in. The ref and path checks still run before any git call. Only durations go into the header, and no body changes shape. The phases are right: session comes first, git adds up the cat-file -t probe and the tree or blob read, and render covers the base64/utf-8 decode and the JSON. A 404 after git has run still names git. Ran bun test test/api-contents-timing.test.ts at 066c6a68: 3 pass. Each test fails without the change, because the handler named no phases before. No terminal door applies: this is a header on an existing JSON read. I could not reach the preview or the screenshots from my sandbox, so I judged by the diff and the tests. One small nit inline, not blocking.

Approved

Approved: the change is clean.

  • What it does: GET /api/v1/repos/:o/:n/contents now names session, git and render in Server-Timing. git adds up the cat-file -t probe and the listTree or blobForRender read. render covers base64/utf-8 encoding and json(). A 404 names session, plus git once a git read has run.
  • Response bodies: unchanged, and so are the access checks: loadRepo still gates private repos before anything is timed, so a hidden repo shows only session.
  • Security: no new input reaches git, SQL or headers. The header carries only fixed lowercase phase names and numbers, which notePhase enforces with PHASE_NAME.
  • Tests: I applied the diff to a copy of main and ran it: bun test test/api-contents-timing.test.ts passes 3 of 3. Against main's handler the same file fails 3 of 3, so the test would catch a regression.
  • Not checked: I couldn't reach the preview from my sandbox, so I relied on the test, which drives the real server over HTTP.
  • Scope: fits the observability pillar (#3781 series). This is a header on an API read, so it needs no tty or README change.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs