nuxt / fonts

Plug-and-play web font optimization and configuration for Nuxt apps.
https://fonts.nuxt.com
MIT License
448 stars 7 forks source link

Fonts sometimes missing in production build #356

Open CernyMatej opened 1 week ago

CernyMatej commented 1 week ago

I've been having an issue with this module, where the fetching of font files sometimes fails during the production build. I haven't been able to create a reliable reproduction yet—it seems to happen at random.

The build is done in GitHub CI, where a Docker image is built, using Node version 18.

This is the error log from the problematic deployment:

#25 20.31 [@nuxt/fonts]  ERROR  Could not fetch metadata for Red Hat Display from google. fetch failed
#25 20.31 
#25 20.31   at Object.fetch (node:internal/deps/undici/undici:11372:11)
#25 20.31   at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
#25 20.31   at async getFontDetails$5 (/opt/project/node_modules/.pnpm/@nuxt+fonts@0.8.0_ioredis@5.4.1_magicast@0.3.5_rollup@4.20.0_vite@5.4.3_@types+node@22.5.5_sa_d6a46d5cxhijk7lxvuwfjdzkcm/node_modules/@nuxt/fonts/dist/module.mjs:550:12)
#25 20.31   at async cachedData (/opt/project/node_modules/.pnpm/@nuxt+fonts@0.8.0_ioredis@5.4.1_magicast@0.3.5_rollup@4.20.0_vite@5.4.3_@types+node@22.5.5_sa_d6a46d5cxhijk7lxvuwfjdzkcm/node_modules/@nuxt/fonts/dist/module.mjs:474:20)
#25 20.31   at async Object.resolveFontFaces (/opt/project/node_modules/.pnpm/@nuxt+fonts@0.8.0_ioredis@5.4.1_magicast@0.3.5_rollup@4.20.0_vite@5.4.3_@types+node@22.5.5_sa_d6a46d5cxhijk7lxvuwfjdzkcm/node_modules/@nuxt/fonts/dist/module.mjs:511:14)
#25 20.31   at async resolveFontFaceWithOverride (/opt/project/node_modules/.pnpm/@nuxt+fonts@0.8.0_ioredis@5.4.1_magicast@0.3.5_rollup@4.20.0_vite@5.4.3_@types+node@22.5.5_sa_d6a46d5cxhijk7lxvuwfjdzkcm/node_modules/@nuxt/fonts/dist/module.mjs:1395:26)
#25 20.31   at async addFontFaceDeclaration (/opt/project/node_modules/.pnpm/@nuxt+fonts@0.8.0_ioredis@5.4.1_magicast@0.3.5_rollup@4.20.0_vite@5.4.3_@types+node@22.5.5_sa_d6a46d5cxhijk7lxvuwfjdzkcm/node_modules/@nuxt/fonts/dist/module.mjs:940:22)
#25 20.31   at async Promise.all (index 0)
#25 20.31   at async transformCSS (/opt/project/node_modules/.pnpm/@nuxt+fonts@0.8.0_ioredis@5.4.1_magicast@0.3.5_rollup@4.20.0_vite@5.4.3_@types+node@22.5.5_sa_d6a46d5cxhijk7lxvuwfjdzkcm/node_modules/@nuxt/fonts/dist/module.mjs:1013:5)
#25 20.31   at async Object.transform (/opt/project/node_modules/.pnpm/@nuxt+fonts@0.8.0_ioredis@5.4.1_magicast@0.3.5_rollup@4.20.0_vite@5.4.3_@types+node@22.5.5_sa_d6a46d5cxhijk7lxvuwfjdzkcm/node_modules/@nuxt/fonts/dist/module.mjs:1025:17)
#25 20.31 
#25 20.31 
#25 20.31 [@nuxt/fonts]  WARN  Could not produce font face declaration from google for font family Red Hat Display.
#25 20.31 
#25 42.48 ℹ ✓ 1387 modules transformed.

Has anyone else come across this issue? Wouldn't it be better to exit rather than continue with the build if the font fetch fails?

danielroe commented 1 week ago

yes, it might be worth retrying the fetch a couple of times, and if not - failing the build ...

we can implement in https://github.com/unjs/unifont.