tailwindcss icon indicating copy to clipboard operation
tailwindcss copied to clipboard

Invalid CSS causes entire page to crash with STATUS_BREAKPOINT

Open coscura opened this issue 8 months ago • 2 comments

What version of Tailwind CSS are you using?

v4.0.17

What build tool (or framework if it abstracts the build tool) are you using?

postcss 8.5.3, React 18.3.1, Vite 6.0.3

What version of Node.js are you using?

v22.0.0

What browser are you using?

Chrome, Vivaldi, WebView2 (Tauri app)

What operating system are you using?

Windows

Reproduction URL

https://play.tailwindcss.com/Et6k9kAgbw

Describe your issue

I'm working with Tauri, Vite, React, and tailwindcss (with postcss transformer defined in vite.config.js). One specific class with 3 modifiers (file:disabled:dark:bg-green-500) generates some invalid CSS which in turn crashes the entire page with STATUS_BREAKPOINT, this happened to me on both Chrome and WebView2 on Windows. I have @custom-variant dark (&:is(.dark *)); in my css file, I copied a similar variant from tailwind docs and used it in the playground with the same error occurring. Removing the custom variant generates @media modifiers instead and fixes the issue.

Image

coscura avatar Mar 26 '25 20:03 coscura

As a work-around, you could swap the order of the variants around so that file is last: https://play.tailwindcss.com/JWVIoFRqIL

I think this might be similar to #16582 (though with very different error symptoms), whereby it is invalid to have nested rules inside a pseudo-element rule.

wongjn avatar Mar 26 '25 21:03 wongjn

Gonna have to file a browser bug for this one.

(also move the file variant to the front, the dark: selector appearing inside a pseudo element is invalid. Things like :active, :disabled, and :hover can potentially be valid depending on the browser)

Minimal repro is just this HTML:

<style>
  .foo::file-selector-button {
    &:disabled {
      &:where(.bar *) {
        background-color: red;
      }
    }
  }
</style>

Notes for me when filing the bug:

  1. Moving :disabled to the top-level selector stops the crash
  2. Nesting is required for the crash to happen
  3. Removing :disabled or :where(…) stops the crash
  4. &:where(.bar) does not crash but &:where(.bar *) does

thecrypticace avatar Mar 27 '25 00:03 thecrypticace

I don't know what version of Chrome this got fixed in but it doesn't appear to crash any longer.

thecrypticace avatar Sep 18 '25 18:09 thecrypticace