fix(producer): fall back to a temp dir when the font cache is unwritable - #3425
Open
miguel-heygen wants to merge 1 commit into
Open
fix(producer): fall back to a temp dir when the font cache is unwritable#3425miguel-heygen wants to merge 1 commit into
miguel-heygen wants to merge 1 commit into
Conversation
The font cache holds Google Fonts downloads between runs. It is an optimisation — the bytes are still fetchable without it — but failing to create it was fatal, because `fontCacheDir` called `mkdirSync` unguarded during compile and the throw propagated straight out of the render. A first-time user on 0.8.8 lost their very first render to it: EPERM: operation not permitted, mkdir '<home>/.cache/hyperframes/fonts/inter' and the remediation the CLI offered was "Try --docker for containerized rendering", which does not address an unwritable host directory. Fall back to one temp root per process — the same shape the Lambda cache root in this file already uses — and warn once with the env var that makes the fallback unnecessary. A run still de-duplicates its own downloads; it just cannot reuse them next time. Reproduced end to end before and after: pointing HYPERFRAMES_FONT_CACHE_DIR at a path under a chmod 500 parent used to print "Render failed / EACCES" and now renders, emitting a single actionable warning. Closes #3412.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
An unwritable font cache directory no longer aborts the render. It falls back to a temp
directory and warns once.
Closes #3412.
Why
The font cache holds Google Fonts downloads between runs. It is an optimisation — the
bytes are still fetchable without it — but failing to create it was fatal, because
fontCacheDircalledmkdirSyncunguarded during compile and the throw propagated out ofthe render.
A first-time user on 0.8.8 lost their very first render to it:
Two things made it worse than the bug. The CLI's remediation was
Try --docker for containerized rendering, which does not address an unwritable host directory. AndHYPERFRAMES_FONT_CACHE_DIR— which would have rescued them — appears in no user-facingguide page.
How
fontCacheDirnow catches the failure and falls back to one temp root per process, the sameshape the Lambda cache root a few lines above already uses:
A run still de-duplicates its own downloads; it just cannot reuse them next time. The
one-time warning names
HYPERFRAMES_FONT_CACHE_DIR, so the escape hatch is discoverable atthe moment it is needed.
Test plan
End to end, before and after. Pointing
HYPERFRAMES_FONT_CACHE_DIRat a path under achmod 500parent, rendering a composition that requests Inter.Before:
After:
New regression test
deterministicFonts-unwritableCache.test.tsdrivesinjectDeterministicFontFaceswith the cache root under a read-only parent. Verified itfails on the unfixed code rather than assuming:
All
deterministicFontssuites green: 61 pass across 8 files.Not covered
Try --dockerremediation is unchanged. It is emitted generically forrender failures, so fixing it is a separate change about how that hint is chosen.
HYPERFRAMES_FONT_CACHE_DIRis still absent from the docs site. Now surfaced in thewarning, but a real docs page would be better.