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

The API's pull review states read names its Server-Timing phases: session, reviews, render #4933

Merged opened this

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

Merged

`GET /api/v1/repos/:owner/:name/pulls/:number/review-states` now answers a `Server-Timing` header naming `session`, `reviews` and `render`, in that order. The type check is clean, and the new test and the existing review tests pass (21 tests).

shipped production is serving it deploy 2fa0c24

opened this

GET /api/v1/repos/:owner/:name/pulls/:number/review-states now answers a Server-Timing header naming session, reviews and render, in that order. The type check is clean, and the new test and the existing review tests pass (21 tests).

  • Handler: in src/http/api.ts, session is noted with takeSessionTime before the pull is loaded, reviews wraps listReviews and readerMarked, and render wraps the json call. Only this handler changed, and the response body is the same as before.
  • Test: test/api-rstates-timing.test.ts opens a pull and asserts the header names exactly those three phases in order. It fails if a phase is dropped.
  • Not done: the POST handler for review-states is untouched. On an unknown pull the header names only session, and I did not add a test for that case.

To try it, curl -si the route and read the Server-Timing header.

Closes #4927

commented

GET /api/v1/repos/:owner/:name/pulls/:number/review-states now answers a Server-Timing header naming session, reviews and render, in that order. The type check is clean, and the new test and the existing review tests pass (21 tests).

  • Handler: in src/http/api.ts, session is noted with takeSessionTime before the pull is loaded, reviews wraps listReviews and readerMarked, and render wraps the json call. Only this handler changed, and the response body is the same as before.
  • Test: test/api-rstates-timing.test.ts opens a pull and asserts the header names exactly those three phases in order. It fails if a phase is dropped.
  • Not done: the POST handler for review-states is untouched. On an unknown pull the header names only session, and I did not add a test for that case.

To try it, curl -si the route and read the Server-Timing header.

Approved

Clean. The GET review-states handler names its phases session, reviews and render in the same way as the timed API routes next to it (notePhase + takeSessionTime, then timePhase). The response body, the auth path (loadPull → access check) and readerMarked are unchanged, so nothing new is exposed. Server-Timing carries durations only, no data. I checked the new test: it passes at the head and fails against the base handler. On the preview, an unknown pull answers 404 with server-timing: app;…, session;…, so the change is live. The preview has no repos, so the 200 path is covered only by the test. Neither the terminal nor the README is affected, because this is response-header instrumentation only. Leaving the POST untimed is a reasonable scope.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs