tailwindcss: cli hangs on version 4.0.16
What version of Tailwind CSS are you using?
v4.0.16
What build tool (or framework if it abstracts the build tool) are you using?
tailwind-cli
What version of Node.js are you using?
21.7.3
What browser are you using?
N/A
What operating system are you using?
macOS
Describe your issue
Just noticed this on a deploy to Heroku, our normal build step for Tailwind is hanging. No issues locally until I force it to install 4.0.16 and then it just hangs. No errors. I don’t see a debug or verbose output option for the cli so I’m not sure what to do to further troubleshoot. Adding "@tailwindcss/cli": "4.0.15" to package.json, to force a downgrade to 15, and all is well again.
npx @tailwindcss/cli -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css --minify
Need to install the following packages:
@tailwindcss/cli@4.0.16
Ok to proceed? (y)
*hangs* here, no output
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 4
- Comments: 38 (18 by maintainers)
Commits related to this issue
- Fix Ruby files causing the CLI to hang (#17383) Fixes #17379 The preprocessor we added to detect embedded languages uses a back reference and given a long enough file with certain byte / character p... — committed to tailwindlabs/tailwindcss by thecrypticace 2 years ago
- Fix Ruby files causing the CLI to hang (#17383) Fixes #17379 The preprocessor we added to detect embedded languages uses a back reference and given a long enough file with certain byte / character p... — committed to tailwindlabs/tailwindcss by thecrypticace 2 years ago
- Fix Ruby files causing the CLI to hang (#17383) Fixes #17379 The preprocessor we added to detect embedded languages uses a back reference and given a long enough file with certain byte / character p... — committed to tailwindlabs/tailwindcss by thecrypticace 2 years ago
- Fix Haml pre-processing crash when there is no `\n` at the end of the file (#18155) This PR fixes a Haml pre-processing issue where a crash occurs if there is no trailing `\n` at the end of the file ... — committed to tailwindlabs/tailwindcss by RobinMalfait a year ago
Hey folks! A fix for this went out with the latest patch release now. Please let us know if there are still any issues. Thanks a ton for helping us track this down and getting this resolved quickly!
Okay, I found the problem! It’s the back reference we’re using in the regex. It appears to be causing exponential backtracking when a string is long enough and has certain patterns. I’ve got it running just against some HTML that’s about ~10KB and it happens. The Ruby example I got down to as little as 4070 bytes before it started causing problems.
I’ve gotta figure out how to replace it with something but the problem has at least been identified.
@luizkowalski oh I wonder if there are hidden folders from builds or something that are getting scanned maybe?
Another thing to try is this:
Which completely disables automatic source detection — would be a pretty definitive answer to “is it our file scanning or something else”
Thank you all for your quick work! Confirming that 4.0.17 has resolved the issue here.
Ah yep you’re right. Alright I’ve got a repro. Gonna see if I can get this down to the actual bug. Thank you much!
@muriloime nice find! I can reproduce this and will open a fix for this, thanks!
Oh… that one hangs in Bun but not in Node. That’s bizarre. Thanks!
ok, I managed to narrow it down to this reproducible piece: https://github.com/luizkowalski/repro-tailwind-bug
using bun,
bun run build:csswill hangI’ve had the same issue on a ruby project, using 4.0.16. Downgrading to 4.0.15 solved the issue. I’ll see if I can catch the view (
html.erb, html.slimorhtml.haml) file that would be causing this issue and get a docker image for you to work on.