-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cli hangs on version 4.0.16 #17379
Comments
Heya! Just tried the cli on the tailwindcss.com website and it seems fine:
Do you have a repro that you can share? It might also help to append
|
@neontuna @luizkowalski are you both scanning Ruby template files? If so, can you do a grep for |
it returned nothing in my case. I noticed I had some heredocs on my views like this: <%= button_to account_path(account),
method: :delete,
class: "account--disconnect-button",
data: {
turbo_confirm: "Are you sure you want to unlink this account?",
confirm_details: <<~CONFIRM.html_safe,
Any circuits and calendars from this account will be deleted.
<br/>
<br/>
<small>Note: This account can always be reconnected later. (if you still have access to it)</small>
CONFIRM
confirm_button: "Disconnect",
} do %> which I tried to remove just in case, but it had no effect, cli still hanging |
@luizkowalski Thanks for checking! Yeah that theory also doesn't check out when I tried to set up a reproduction locally. I wonder if it's possible that you can share your setup so we can run it? If not, maybe you could:
You're experiencing this issue on macOS running bun (no Docker etc.), correct? |
I'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 ( |
Same issue for me. Downgrading to |
We still haven't been able to reproduce this issue so any more information would be helpful, maybe someone can share a repo that experiences this issue? @outerim Are you using the CLI with a Rails site as well? Are you running the command on macOS, Windows, or Linux and with or without a Dockerfile? |
Unfortunately can't share the proprietary repo where this occurs. We're using Rails with Phlex for templating. This is happening in a docker container, base image is the public docker ruby:3.4-slim image. Is there a patch I could apply to get tailwind cli to print out the file it's processing when the infinite loop occurs? |
No, there is not a patch for that. I think the problem might be happening in native code which would then require recompiling, replacing the .node file, etc… |
@outerim Do you have any |
Trying to see if I can get you a reproduction now. prepending This is a fairly large Rails project but on a test branch I've essentially deleted everything except a single html file with macOS 15.3 (24D60) Should note that this is also happening on Heroku deploy, which is a container of some sort, but we're not running Docker or anything locally. |
I don't know if this helps but this is the output of build on 4.0.15 using my stripped down app
and debug output
|
I'm trying to copy everything I can to another folder so I can create a reproducible project but so far, it is working...just doesn't work on the real project. I also tried to remove everything from |
@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" |
This got it working on our stripped down app
|
exactly what @neontuna posted too |
Okay! That is super useful knowledge. Now the question is… why is this happening. Having some example file that's being scanned would be useful. |
Does the cli just recursively scan everything within the current folder? Or is it "aware" of things like the Rails project structure? I could start dumping stuff like the tmp directory etc. |
it's effectively the current folder. It does do some scanning up directories for .gitignores and what not but it shouldn't touch things like |
Something I'd try is:
Then basically putting the dir back and repeating with its contents |
so I started deleting all my views, folder by folder, and at some point, it worked, but I can't pinpoint a specific view. As soon as I deleted most of them, it started to work again so the problem has to be in the |
I imagine there may be multiple views that exhibit the problem. Especially since multiple people are running into this so it must be some common pattern too |
I've got it narrowed down to the spec and db folders of our project |
I have this problem in a Ruby on Rails app. A new app works just fine, but an old existing one doesn't. I created a new empty folder and started carrying files there. For me, it also broke after copying the spec folder. And this suggestion with the |
I can't troubleshoot much more today but maybe this will help point in the right direction. This big chunk of the spec file is what's causing it to fail. I just can't seem to narrow down what part of it is causing it. Maybe just the amount of nesting? Or that it looks similar to JSON?
|
ok, I managed to narrow it down to this reproducible piece: https://github.com/luizkowalski/repro-tailwind-bug using bun, |
Oh… that one hangs in Bun but not in Node. That's bizarre. Thanks! |
Oh and your repro is using 4.0.15 and not 4.0.16 |
|
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! |
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. |
Trying to debug the same issue: This works: This does not, it hangs and never completes: As suggested above, changing the @import to: Then re-running with bunx and it completes. |
Fixes #17379 The preprocessor we added to detect embedded languages uses a back reference and given a long enough file with certain byte / character patterns it'll cause what appears to be an indefinite hang (might just be catastrophically exponential backtracking but not sure) This replaces the one regex w/ back references with two, anchored, multi-line regexes Now we search for all the starting & ending delimiters in the file. We then loop over all the starting delimiters, find the paired ending one, and preprocess the content inside --------- Co-authored-by: Philipp Spiess <[email protected]>
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! |
Thank you all for your quick work! Confirming that 4.0.17 has resolved the issue here. |
I am sorry to inform you that this problem still persist for me even with 4.0.17 version. Completely random - when it hungs up I press Is there anything I can do to get more info from Some debug info:
Thanks. |
@herko If you're not seeing the problem every time then what you're experiencing is likely a different bug. Can you provide a reproduction? |
Fixes #17379 The preprocessor we added to detect embedded languages uses a back reference and given a long enough file with certain byte / character patterns it'll cause what appears to be an indefinite hang (might just be catastrophically exponential backtracking but not sure) This replaces the one regex w/ back references with two, anchored, multi-line regexes Now we search for all the starting & ending delimiters in the file. We then loop over all the starting delimiters, find the paired ending one, and preprocess the content inside --------- Co-authored-by: Philipp Spiess <[email protected]>
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.The text was updated successfully, but these errors were encountered: