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

Settings › Capacity's warm answer is read for its app time the way /search's is, and a test holds it #9744

Merged opened this

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

Merged

Settings › Capacity's warm answer now has a test like the one /search has (#9715). Only `test/capacity-timing.test.ts` changes: `src/web/pages/capacity.ts` stays as it is because the new test passes on main.

shipped production is serving it deploy a5a2512

opened this

Settings › Capacity's warm answer now has a test like the one /search has (#9715). Only test/capacity-timing.test.ts changes: src/web/pages/capacity.ts stays as it is because the new test passes on main.

The new test loads the page as an admin twice. On the second (warm) answer it:

  • reads the app phase of Server-Timing with the same appMs helper shape as test/search-page.test.ts, and fails if it is NaN. The time is reported, never compared to a limit (#4429).
  • holds the 50 ms bound as work: requestStatements plus expectWork against the existing WARM_STATEMENTS ceiling of 64, unchanged.
  • checks that no git process starts. It watches both Bun.spawn and Bun.spawnSync and counts calls whose program is git, whether the command comes as a list or as { cmd }. capacity.ts does not start git at all, so this guards against a future change that would.

Not done: no wall-clock limit, since a busy runner would make it flaky, as the issue warns.

Try it: bun test test/capacity*.test.ts. It ran 63 tests across 8 files with no failures. bun x tsc --noEmit is clean, and bun scripts/gate.ts printed no complaints.

🤖 Generated with Claude Code

Closes #9740

commented

Settings › Capacity's warm answer now has a test like the one /search has (#9715). Only test/capacity-timing.test.ts changes: src/web/pages/capacity.ts stays as it is because the new test passes on main.

The new test loads the page as an admin twice. On the second (warm) answer it:

  • reads the app phase of Server-Timing with the same appMs helper shape as test/search-page.test.ts, and fails if it is NaN. The time is reported, never compared to a limit (#4429).
  • holds the 50 ms bound as work: requestStatements plus expectWork against the existing WARM_STATEMENTS ceiling of 64, unchanged.
  • checks that no git process starts. It watches both Bun.spawn and Bun.spawnSync and counts calls whose program is git, whether the command comes as a list or as { cmd }. capacity.ts does not start git at all, so this guards against a future change that would.

Not done: no wall-clock limit, since a busy runner would make it flaky, as the issue warns.

Try it: bun test test/capacity*.test.ts. It ran 63 tests across 8 files with no failures. bun x tsc --noEmit is clean, and bun scripts/gate.ts printed no complaints.

🤖 Generated with Claude Code

Approved

Test-only change; it matches the issue. appMs has the same shape as search-page.test.ts. The second (warm) admin answer is checked for a sent app phase, statements are bounded by the unchanged WARM_STATEMENTS via requestStatements and expectWork, and no git is spawned. test/capacity-timing.test.ts passes locally (3 pass). The preview answers 303 to an unauthenticated request, as expected. Two next things: (1) the spawn spy only sees Bun.spawn and Bun.spawnSync, so also cover node:child_process if capacity.ts ever imports it; (2) the dedicated spawn-spy test duplicates the setup of the earlier tests in the file, so extract a shared admin-get helper.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs