-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
fix: Update regex for formatting assertion messages to avoid catastrophic backtracking #29353
Conversation
…ly before regex runs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a regression test for what caused the issue in the first place by asserting on the Base64 encoded image?
@AtofStryker Yah, I'm trying to do that. It's kind of hard to find a test case in the goldilocks zone that fixes it but doesn't make a really long test. I'm about to try to replicate exactly what the plugin does as a test. |
Concerned that a test could be performant on my Mac, but then hang on CI. It seems very specific to a certain size of string where it starts hanging. I opened a PR to add a test at some point: #29356 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since performance testing base64 is somewhat difficult, we are going to create an issue to add a regression test and continue with merging the revision.
Passing run #55011 ↗︎
Details:
Review all test suite changes for PR #29353 ↗︎ |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Additional details
This fixes a regression that was introduced in #29243. Those changes can result in catastrophic backtracking when trying to match long assertion messages via the new Regex.
Additionally, I did restructure some of the code so that if certain conditions are not met where the message does not need to be run through the regex, it is no longer run through the regex. This should improve performance for some commands that were needlessly going through the regex check.
Steps to test
Run this repo with 13.7.3 and run it with this branch. The test should now pass in this branch.
I tried to write a test to ensure Cypress does not hang, but my test seems unpredictable. I haven't figured out the exact size of the assertion of content that will cause it to hang before and not after (without it being a complicated test including the plugin). I intend to followup with a PR to test this and am favoring getting this out quickly.
How has the user experience changed?
Before
After
PR Tasks
cypress-documentation
?type definitions
?