next.js: Turbopack error when using roboto flex font

Link to the code that reproduces this issue

https://github.com/Arctomachine/next-font-roboto-flex-bug

To Reproduce

Start dev server and open page in browser

Current vs. Expected behavior

Current: gives error 500 when following is present. Error happens when constant is assigned. Other fonts from roboto family work

import { Roboto_Flex } from 'next/font/google'

const robotoFlex = Roboto_Flex({
  subsets: ['latin'],
})

Expected: works with this font

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Pro
  Available memory (MB): 32720
  Available CPU cores: 12
Binaries:
  Node: 20.17.0
  npm: 10.8.2
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 15.1.1-canary.23 // Latest available version is detected (15.1.1-canary.23).
  eslint-config-next: N/A
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.3.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Font (next/font), Turbopack

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 16 (4 by maintainers)

Most upvoted comments

Did some digging and found where the path was too long. Applied a fix in #79089. It’s available on next@canary right now. Please give it a try!

@Arctomachine I was able to replicate it on Windows!

This issue caused by turbopack (at least for me it’s only happening when app running in turbo mode), probably in Windows only. The following error is thrown on server side: { name: "TurbopackInternalError", message: "path length for file C:\\Projects\\NextJS\\my-project\\.next\\static\\media\\NaN4epOXO_NexZs0b5QrzlOHb8wCikXpYqmZsWI___OGbt8jZktqc2V3Zs0KvDLdBP8SBZtOs2IifRuUZQMsPJtUsR4DEK6cULNeUx9XgTnH37Ha_FIAp4Fm0PP1hw45DntW2x0wZGzhPmr1YNMYKYn9_1IQXGwJA_f8bbf1b444194d5822b2052cf4cadf07.00c990aa.woff2 exceeds max length of filesystem\n\nCaused by:\n- file is too long, and could not be normalized", "Error: path length for file C:\\Projects\\NextJS\\my-project\\.next\\static\\media\\NaN4epOXO_NexZs0b5QrzlOHb8wCikXpYqmZsWI___OGbt8jZktqc2V3Zs0KvDLdBP8SBZtOs2IifRuUZQMsPJtUsR4DEK6cULNeUx9XgTnH37Ha_FIAp4Fm0PP1hw45DntW2x0wZGzhPmr1YNMYKYn9_1IQXGwJA_f8bbf1b444194d5822b2052cf4cadf07.00c990aa.woff2 exceeds max length of filesystem\n\nCaused by:\n- file is too long, and could not be normalized" }

Seems like for some reason, when TurboPack is used, this font downloaded with a very long file name generated that causing TurboPack to fail. The workaround is using Webpack or LocalFont for this specific font, but definitely it will be better if NextJS team will fix that issue. I was trying to enable LongPathsEnabled setting in registry (Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem), but it didn’t help… Seems like it’s a limitation of the TurboPack or NodeJS itself…

I’m using Node 20.18.0 btw. It could be that with latest Node versions this issue is resolved…