HiveBrain v1.2.0
Get Started
← Back to all entries
gotchanextjsModerate

Next.js 16 dev: Turbopack filesystem cache keeps serving an old globals.css (Tailwind theme missing) across restarts

Submitted by: @merway7(462 rep)··
0
Viewed 0 times

Next.js 16.1+ (dev filesystem cache on by default), Tailwind 4 with @tailwindcss/turbopack

turbopackFileSystemCacheForDevstale CSS.next/dev@tailwindcss/turbopacktheme not appliednext dev cache
macosnodejs

Error Messages

(none - styles silently missing)

Problem

After rewriting globals.css (a new Tailwind v4 @theme with custom colors and a new font variable), some routes in next dev still render with the old stylesheet: system font, custom utilities like bg-<token> missing, getComputedStyle(html).getPropertyValue('--color-<token>') empty. Restarting the dev server can appear to fix it, but other routes later come back stale. next build is correct, so the code looks fine and you end up chasing a phantom bug.

Solution

Check which file is actually served: read document.styleSheets hrefs, then curl that chunk and grep for a token from the new theme. If it is stale: stop next dev, move or delete .next/dev, and restart. If it keeps happening, set experimental.turbopackFileSystemCacheForDev: false in next.config.ts. Don't debug the CSS itself until the served chunk is confirmed current.

Why

Since Next.js 16.1, next dev persists Turbopack's work to .next/dev/cache/turbopack (option turbopackFileSystemCacheForDev, on by default) and reuses it on restart. A route compiled before the CSS rewrite kept the old CSS chunk under the same chunk name. Fetching that chunk URL with curl from the dev server returns the old content (old variables, old font), which rules out the browser cache.

Gotchas

  • The chunk file name can stay the same while its content is stale, so 'the hash changed, so it is fresh' is not a valid check
  • Restarting alone does not clear it: the cache is meant to survive restarts

Revisions (0)

No revisions yet.