-
-
Notifications
You must be signed in to change notification settings - Fork 280
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
performance: templ parse takes a long time and uses high CPU when unclosed void elements are used #886
Comments
Here is the time it takes after adding one more case with a ❯ templ generate (increase by ~20 seconds) |
It's the unclosed Once A fix would be for the parser to give up trying to look for the |
The parser is slow because, imagine this scenario ("element: void nesting same is OK" test). People sometimes accidentally put elements inside void elements, so it's not clear what the intent is. <div><br><br></br></div> How should templ handle this? <br>
<br>
</br> Or... <br>
<br></br> Or an error complaining about a void element having nested content? Or strip the nested content? Or ignore closers for void elements? |
Ah I see... ok... |
Cool... I was able to get the message you show in the screenshot. but I dont get any if I just put a Also Out of your comments from yesterday I feel that errors or warnings are the way to go. if the parser has difficulties with this kind of scenario that is fair, I just feel it would be great if the lsp could warn for that early :-) (Amazing work on this project btw, finally a templating system for go that is mostly enjoyable to use) |
In the PR, I think I've sorted the performance out. If you have time to build templ in the PR and try it out, that would be great. The "install-snapshot" task in the README does the required stuff. |
Awesome, I tested this on my little repo with the snapshot and it performs as expected, thanks a lot for the quick fix :-) |
Describe the bug
With the code I show here templ takes VERY long to compile, about 29 seconds. If I add more cases to the switch case it takes even longer, to the point where it is completey unusable and locked.
If I just remove the inputs in the top of the ActionStep template it goes below one second again...
This seems like a really funkey scanner issue to me, but I am sure you are much faster in finding the actual issue...
the templ process also climbs to ridiculous CPU usage while trying to generate in this case...
To Reproduce
Repo: https://github.com/s00500/templ-switchcaseissue
Expected behavior
Fast compile, no lockup
Logs
templ info
outputDesktop (please complete the following information):
macOS (latest, sonoma 14.6.1)
❯ templ version
v0.2.759
(Masterbuild from today)
The text was updated successfully, but these errors were encountered: