Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fonts intermittently don't load in development environment #61

Closed
jbritain opened this issue Jul 29, 2023 · 8 comments · Fixed by #95 or #137
Closed

Fonts intermittently don't load in development environment #61

jbritain opened this issue Jul 29, 2023 · 8 comments · Fixed by #95 or #137
Assignees
Labels
bug Something isn't working

Comments

@jbritain
Copy link
Member

Sometimes when running yarn dev, the console throws up the following errors

FetchError: request to https://fonts.googleapis.com/css2?family=Rubik:[email protected]&display=swap failed, reason: 
    at ClientRequest.<anonymous> (/home/joshua/Documents/Programming/frontend/node_modules/next/dist/compiled/node-fetch/index.js:1:65756)
    at ClientRequest.emit (node:events:511:28)
    at TLSSocket.socketErrorListener (node:_http_client:495:9)
    at TLSSocket.emit (node:events:511:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)
    at runNextTicks (node:internal/process/task_queues:64:3)
    at listOnTimeout (node:internal/timers:540:9)
    at process.processTimers (node:internal/timers:514:7) {
  type: 'system',
  errno: 'ENETUNREACH',
  code: 'ENETUNREACH'
}
- error Failed to download `Rubik` from Google Fonts. Using fallback font instead.
FetchError: request to https://fonts.googleapis.com/css2?family=Orbitron:[email protected]&display=swap failed, reason: 
    at ClientRequest.<anonymous> (/home/joshua/Documents/Programming/frontend/node_modules/next/dist/compiled/node-fetch/index.js:1:65756)
    at ClientRequest.emit (node:events:511:28)
    at TLSSocket.socketErrorListener (node:_http_client:495:9)
    at TLSSocket.emit (node:events:511:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)
    at runNextTicks (node:internal/process/task_queues:64:3)
    at process.processTimers (node:internal/timers:511:9) {
  type: 'system',
  errno: 'ENETUNREACH',
  code: 'ENETUNREACH'
}
- error Failed to download `Orbitron` from Google Fonts. Using fallback font instead.

The result of this is that the site resorts to using the default serif font, as shown
image

Apart from the fact that the fonts don't load, we ought to also ensure that the fallback font is a sans serif font as opposed to a serif one.

@nitishdhar
Copy link
Collaborator

This is still happening - Mac, Edge Browser running yarn dev

Screen Shot 2023-08-26 at 9 14 47 PM

@nitishdhar nitishdhar linked a pull request Aug 27, 2023 that will close this issue
@nitishdhar
Copy link
Collaborator

It seems to work fine with --turbo but happens when not using turbo.

@nitishdhar
Copy link
Collaborator

Another related issue for the fetch failure - vercel/next.js#45080

@nitishdhar
Copy link
Collaborator

@jbritain - so there are two issues here -

  1. No console error but the fonts don't render in dev environment
  2. Console error for fetch of the fonts from google

For 1., I have pushed this fix #95 but for 2., there isn't a clean fix yet (vercel/next.js#45080) but there's a workaround, just delete you .next folder and and run yarn dev again.

@fuomag9
Copy link

fuomag9 commented Oct 24, 2023

This still does not work for me, using curl via the terminal works fine so it's not a network issue

@ziin
Copy link

ziin commented Oct 28, 2023

It seems to work fine with --turbo but happens when not using turbo.

I had this fetch problem only in development and I fixed it using the --turbo flag.

@sumairq
Copy link

sumairq commented Jan 22, 2024

Deleting the .next folder and regenerating it does not work for me.
Adding --tubo flag to my dev script works "dev": "next dev --turbo",
However, we should not be needing the turbopack just so the fonts load properly in the development environment. I hope this issue gets fixed soon.

I am running "next": "14.0.4" with node v20.6.1.

@aslink87
Copy link
Member

I finally got this to happen to me as well. I've made a pr to switch entirely to local fonts. #137

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: 🎉 Done
6 participants