Repository navigation
feat(core): log one line of font counts per compile - #9045
Conversation
A compile that resolves fonts now writes a single info line with how many families it resolved, how many stylesheet lookups and font files came from the cache or the network, and how many failed. It also counts a shipped family that kept only its shipped faces because the extra ones could not be fetched, which wrote nothing before. The line holds numbers and the fetch mode only: no family name, address or page text. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
jerry-heygen
left a comment
There was a problem hiding this comment.
Changes requested at 2992b491. The new files_failed counter misses font-file fetches that throw. In packages/core/src/fonts/deterministicFonts.ts:1498, the WOFF2 lookup increments total up front, but only a returned non-OK response increments nonOk at line 1519. A network rejection in open mode returns null without incrementing a failure counter; in closed mode, an exhausted retry throws before that counter too. A compile with one such failed file can log files=1 files_failed=0, undercounting the outages this line is meant to make visible.
Count terminal lookup errors separately from HTTP statuses and include them in the summary. Preserve cancellation and retry behavior, and add a regression for a fetch that rejects rather than returning a 404. Hosted CI was still running when inspected; I did not run a live render.
— Jerrai (pr-review)
A file fetch that rejected was counted in files but in no outcome field. Count it per attempt and write it as files_errored, so files always equals the sum of its outcome fields. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
jerry-heygen
left a comment
There was a problem hiding this comment.
Approved at e4c93093. A font-file lookup that throws now increments files_errored, separately from the HTTP failures in files_failed. The new regressions cover a rejected fetch in open and closed mode, and the summary tests check that each file lookup has one counted outcome in the cases they exercise. The fix preserves the caller-abort check and the closed-mode error path.
To count file failures across both categories, use files_failed + files_errored. The hosted core suite had not completed when I checked; I did not run a live render.
— Jerrai (pr-review)
Edit accuracy: accurate 275 (base branch 273), smooth 66 of thoseThe gate passes. Newly passing (2)
Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)
Quarantined, measured but not gated (0) |
What
A compile that resolves fonts now writes one info line with counts of what happened: families resolved, stylesheet lookups and font files served from the cache or fetched, and how many failed.
Why
Today a compile says which family it fetched and warns when a family has no mapping, but nothing adds it up, and one case writes nothing at all: a shipped family that kept only its shipped faces because the extra ones could not be fetched. One line per compile makes cache hit rate and fetch failures countable from logs.
Related work
None.
How
summarizeFontDiagnosticsturns the record the resolver already keeps intoname=valuepairs, andinjectDeterministicFontFaceslogs it once after resolution, including when the compile stops on a font error. A page that asks for no font writes no line.Test plan
Run: the 9 new tests and the whole
packages/coresuite (364 files, 7,586 tests) pass locally. Not run: the producer and CLI suites, and no real render.No visible change
Logging only. No studio or player file changes, and rendered output is the same.
Claude Fable 5.2
The line
mode:closedwhen the compile requires every font, elseopen.bundled_faces_only: resolved shipped families where no extra-face lookup produced a usable file.css_cache_hit: lookups answered from memory or disk.css_failed: lookups with no response or a non-2xx status.files_*: font files named by those lookups, split by cache hit, fetched, and failed.The line holds numbers and the mode only. It never carries a family name, an address or page text; a test asserts its exact shape.
Self-review
injectDeterministicFontFacesis the only entry that creates the record, so every caller gets the line. Existing log lines and the error contract are untouched; the existing diagnostics tests pass unchanged.finally, so it appears once when resolution throws (test: "is written once when a compile that requires every font stops on an unresolved one"). The summary is pure arithmetic over an in-memory record and cannot throw on its own input.files_errored, and the test helper asserts on every line thatfilesequals the sum of its four outcome fields; a caller cancel is the one case with no outcome recorded. They run in the default core suite.🤖 Generated with Claude Code