From c72870bd89347d49d020a4cb0b6959e2261c6949 Mon Sep 17 00:00:00 2001 From: Akshay Kumar Sharma <25038017+akzarma@users.noreply.github.com> Date: Thu, 6 Aug 2026 19:33:39 +0530 Subject: [PATCH] fix(compiler): split font-family only on top-level commas parseFontFamilyValue() split the family stack on every comma, so `font-family: var(--brand-font, inherit)` became two tokens: `var(--brand-font` and `inherit)`. The var() guard from #1655 only skips tokens starting with `var(`, so the orphan fragment was treated as a requested family, failed every resolution path, and aborted fail-closed distributed renders with: FontFetchError: [Compiler] Unresolved fonts in fail-closed mode: inherit). Distributed renders require all fonts to be resolvable. Split on top-level commas only, so a var() expression (including a nested one) stays a single token. Quotes are tracked as well, both so parentheses inside a quoted family name cannot skew the depth counter and so a legal quoted comma no longer splits. Closes #3066 --- .../deterministicFonts-failClosed.test.ts | 11 ++++++ .../src/services/deterministicFonts.ts | 38 ++++++++++++++++++- .../services/render/planValidation.test.ts | 20 ++++++++++ .../distributed/css-var-fonts/src/index.html | 2 +- 4 files changed, 68 insertions(+), 3 deletions(-) diff --git a/packages/producer/src/services/deterministicFonts-failClosed.test.ts b/packages/producer/src/services/deterministicFonts-failClosed.test.ts index 5a1e3c1388..03d56a829c 100644 --- a/packages/producer/src/services/deterministicFonts-failClosed.test.ts +++ b/packages/producer/src/services/deterministicFonts-failClosed.test.ts @@ -253,6 +253,17 @@ describe("injectDeterministicFontFaces — failClosedFontFetch: true", () => { expect(result).toBe(html); }); + it("does NOT throw when font-family uses a CSS var() reference with a fallback", async () => { + const html = `

hello

`; + const result = await injectDeterministicFontFaces(html, { + failClosedFontFetch: true, + fetchImpl: makeFailingFetch(), + }); + expect(result).toBe(html); + }); + it("resolves simple CSS var() font aliases when injecting deterministic fonts", async () => { const html = `