You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a really weird issue and took me waaaaaaaaaayyyy to long to figure out.
I converted a project from windi to unocss today and everything worked great, locally, but my build on github actions stalled. upon verification locally, I could reproduce that.
now followed a few hours of digging and I have pinned the issue down: using < in classes in certain combinations causes a regex catastrophic backtracking.
I managed to debug my way thru stuff and eventually managed to create this minimal repro: https://stackblitz.com/edit/github-y3a65o?file=app.vue
notice how stuff seems to work in pnpm run dev, but pnpm run build just freezes. Removing the < in line 9 fixes the freeze. removing the space + d behind color-red also fixes the freeze.
The issue is this regex: https://github.com/unocss/unocss/blob/main/packages/preset-attributify/src/extractor.ts#L11
If you take that regex and the code that unocss scans for that component into regex101, it will complain about catastrophic backtracking: https://regex101.com/r/Ib1eKA/1
(I obtained the code by console logging the code var here https://github.com/unocss/unocss/blob/main/packages/preset-attributify/src/extractor.ts#L24, before the regex match)
Remove the < and it works, remove the space after the color-red and it works too (as in no match, but no endless loop either).
thats pretty much all find I found out tonight, hopefully that is somewhat helpful to hunt this one down, I tries to understand the regex, but its 2am now and I didn't come far, lol
ps, I know < should be lt in unocss, after talking about the solution to this issue with friends, but I still think this is a valid issue, < could be located elsewhere in the code and theoretically trigger this I think.
The text was updated successfully, but these errors were encountered:
This is a really weird issue and took me waaaaaaaaaayyyy to long to figure out.
I converted a project from windi to unocss today and everything worked great, locally, but my build on github actions stalled. upon verification locally, I could reproduce that.
now followed a few hours of digging and I have pinned the issue down: using < in classes in certain combinations causes a regex catastrophic backtracking.
I managed to debug my way thru stuff and eventually managed to create this minimal repro: https://stackblitz.com/edit/github-y3a65o?file=app.vue
notice how stuff seems to work in pnpm run dev, but pnpm run build just freezes. Removing the < in line 9 fixes the freeze. removing the space + d behind color-red also fixes the freeze.
The issue is this regex: https://github.com/unocss/unocss/blob/main/packages/preset-attributify/src/extractor.ts#L11
If you take that regex and the code that unocss scans for that component into regex101, it will complain about catastrophic backtracking: https://regex101.com/r/Ib1eKA/1
(I obtained the code by console logging the code var here https://github.com/unocss/unocss/blob/main/packages/preset-attributify/src/extractor.ts#L24, before the regex match)
Remove the < and it works, remove the space after the color-red and it works too (as in no match, but no endless loop either).
thats pretty much all find I found out tonight, hopefully that is somewhat helpful to hunt this one down, I tries to understand the regex, but its 2am now and I didn't come far, lol
ps, I know < should be lt in unocss, after talking about the solution to this issue with friends, but I still think this is a valid issue, < could be located elsewhere in the code and theoretically trigger this I think.
The text was updated successfully, but these errors were encountered: