-
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
Random failures over Regexp: Invalid regular expression #1746
Comments
We've seen this |
@houshuang Not sure if you fixed this issue or not but I've managed to get around it by adding I think this might be related to #1396 ? |
I can confirm, adding |
FakeNews... still getting garbage regex error |
I believe that #4698 might fix this issue - browsers infer the character encoding of subresources (partially) based on the character encoding of the consuming HTML document, so fixing the character encoding of HTML in Cypress should cascade to this. I tried using the example in the OP, but that website is not available. If anyone has a reproducible example of this happening, I'll test it against #4698 to see if this fixes the problem. |
Ran this example #2112 (comment) with the #4698 build and I still get invalid regular expression. |
@SeanBE This doesn't seem like an encoding issue, rather, a browser compatibility error. When I add that RegEx, the app no longer works in Firefox: It's because you're using negative lookbehind in the RegEx:
Read more about the development of this feature. Try using We're working on upgrading the Chrome/Electron version bundled with Cypress: #3568 For now, you'll need to run tests in Chrome to support negative lookbehind, or use some other method of pattern-matching to support your needs. I am still looking for a way to reproduce the issue in the OP, which is a character encoding corruption causing an invalid RegEx. |
I have a similar issue where unicode characters in vendor.js are not properly encoded. Problem with creating a repo to reproduce this is that even renaming the project path is enough to get it to behave properly. So I have a repo which can reproduce the problem but only on my machine and only on the exact same path. Creating a new test project on that exact same path also produces the error so it must be caused by something outside the project directory. Installing a previous version of Cypress (3.2.0) fixes the problem. Is it possible that there is something cached somewhere that uses the project path as key? |
@Halt001 Are you using 3.4.1? That release contained some fixes for character encoding. Is your Javascript UTF-8-encoded? What headers is it being sent with from your web server? |
I have to correct myself. It did fix our issue. Best Regards |
Yes, I'm using 3.4.1 The Javascript file I'm talking about is the vendor.js file created by Angular, and it contains UTF8 characters. Request headers as seen in the Chrome instance started by Cypress:
Response headers as seen in the Chrome instance started by Cypress:
After renaming my project directory the problem goes away. For completeness I'll copy the headers below for this working situation. Request headers as seen in the Chrome instance started by Cypress when it all works:
Response headers as seen in the Chrome instance started by Cypress when it all works:
|
What is the name of your project folder when it works, and when it is broken? |
Rename any part of the path, (not necessarily the As there is nothing special about this path and throwing the project away and recreating it from scratch in the exact same location causes the same problem again I suspect that Cypress uses something that is cached beyond the life of the project and also outside the project folder. The project is the Nx dev tutorial until step 2: Tutorial. This is the Repo that contains the tutorial on my machine in the state that it fails. But I'm pretty certain it won't fail anywhere else because as I said, the problem seems to be bound to a specific path. (Run e2e with: Also note that when the server is running and Cypress is failing, opening another Chrome browser manually and opening the same url shows that vendor.js is then correctly served without the utf8 problem. Edit: |
Very interesting observation: It is not the value of the project path that makes the difference but the length. I can rename al I want but as long as it stays the same length it will fail, adding or removing characters in the path will make it work. So this rules out my theory of the path being some kind of key in a cache but it may be possible to reproduce on other machines. Edit: The path name is also in the file contents so the path length impacts the location of the UTF8 characters in vendor.js. This is a long file, could it be that something goes haywire when chunking this file, maybe a byte count vs character count goes wrong when calculating a new chunk? |
Just ran into this issue.
|
We encountered the same issue on nearly all developer machines. Generated javascript assets of Angular gets encoding issues with UTF-8 signs like ɵ sometimes. Any ETA when #4984 will be merged? |
The code for this is done in cypress-io/cypress#4984, but has yet to be released. |
Released in |
I get very strange non-deterministic errors when opening my website in Cypress. It complains about a failing Regexp, but the weird thing is that this never causes a problem in a normal browser, and in fact, even within the Cypress browser, if I open a new tab and reload the code, it works perfectly. And I also added on Cypress.on('uncaught.exception') to my code, which does not seem to help.
Here's my test script:
Here you see two tabs of the same browser, consistently showing completely different behaviour (even when reloading etc). What's very strange is that when I deploy this in 30 different browsers using Kubernetes, I get half of them failing with this error, and the other half working normally! Perhaps this is a timing issue (the reason for the non-determinism) with some interaction between my code and Cypress test code?
Here you see examples of failing and successful Cypress runs - these are exactly the same code in different Kubernetes containers:
(in this case, I don't get the error exceptions, because of the uncaught.exception setting, but the behaviour is exactly the same as in interactive mode, making me believe that the problem is identical).
Reference to Cypress dashboard run
The text was updated successfully, but these errors were encountered: