Skip to content

Bug: Global CSS HMR stale on getStaticPaths() routes in Astro 6 #16780

@thelazylamaGit

Description

@thelazylamaGit

Astro Info

Astro                    v6.3.5
Vite                     v7.3.3
Node                     v22.22.0
System                   Linux (x64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             @astrojs/mdx (v5.0.6)

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

With dynamic routes using getStaticPaths(), changes to my global CSS can leave the CSS state on those pages out of sync. The changes only appear after refresh, or I get an initial flash of the old CSS before the new CSS applies. I only started seeing this after upgrading to Astro 6.

This may not be caused by getStaticPaths() alone. My failing route also renders MDX/content with render(entry), so the MDX/content module graph may be part of the trigger.

My current suspicion is that this is related to the dev CSS invalidation path. Astro collects page CSS through the per-route virtual:astro:dev-css:* module, and it looks like the global CSS change is handled by Vite but does not invalidate that collected route CSS module for this content route. So the page keeps serving previously collected CSS until refresh.

What's the expected result?

I would expect the CSS to correctly update via HMR like with regular routes.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-ovtyzqli?file=src%2Fstyles%2Fglobal.css

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P3: minor bugAn edge case that only affects very specific usage (priority)pkg: astroRelated to the core `astro` package (scope)

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions