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
no-multiple-empty-lines performance issue (hang?) #7893
no-multiple-empty-lines performance issue (hang?) #7893
Comments
Thanks for the report. This is a bit confusing, because we just fixed an issue in 3.13.0 (#7803) where Just to make sure, could you run |
I've looked at the issue before reporting and specifically checked, and confirmed now that Have you tried reproducing it? |
Not yet, I'm planning to look at it a bit later today. Thanks for confirming the ESLint version. |
This fixes an issue where `astUtils.getLocationFromRangeIndex` and `astUtils.getRangeIndexFromLocation` were using a regular expression susceptible to catastrophic backtracking. The match would take quadratic time in the length of the last line of the file. Since the file in #7893 contains a 1.5 million character source map URL on the last line, rules like `no-multiple-empty-lines` would hang when using ast-utils to split the file into lines. This issue only applies to files without trailing newlines, and is only noticable when the last line of the file contains more than 30000 characters or so. Since only a few rules use these `astUtils` functions, this would only appear when either `no-useless-escape` or `no-multiple-empty-lines` reports an error for the file. Simplified example: Node 7.4.0 hangs when evaluating this expression. ```js /[^\n]*\n/.test('A'.repeat(1000000)) ```
This fixes an issue where `astUtils.getLocationFromRangeIndex` and `astUtils.getRangeIndexFromLocation` were using a regular expression susceptible to catastrophic backtracking. The match would take quadratic time in the length of the last line of the file. Since the file in #7893 contains a 1.5 million character source map URL on the last line, rules like `no-multiple-empty-lines` would hang when using ast-utils to split the file into lines. This issue only applies to files without trailing newlines, and is only noticable when the last line of the file contains more than 30000 characters or so. Since only a few rules use these `astUtils` functions, this would only appear when either `no-useless-escape` or `no-multiple-empty-lines` reports an error for the file. Simplified example: Node 7.4.0 hangs when evaluating this expression. ```js /[^\n]*\n/.test('A'.repeat(1000000)) ```
Tell us about your environment
3.13.1
6.9.2
3.10.9
What parser (default, Babel-ESLint, etc.) are you using?
default
Please show your full configuration:
What did you do
Linted a large file: app.txt
(I have changed the extension to .txt in order to attach it to this issue. It is obviously a js file and you should change the extension to the original .js).
What did you expect to happen?
Expected ESLint to produce output in a reasonable amount of time.
What actually happened? Please include the actual, raw output from ESLint.
ESLint did not produce any output after 10 minutes while consuming 100% of 1 CPU core.
The file is a file generated by WebPack. I am aware that linting generated files makes no sense and have added the generated files dir to .eslintignore so that performance on large files per se is not a problem for me.
The reason I would like to see some fix (a timeout? if improving the performance is not possible?) is that I was using ESLint from inside an IDE that became unresponsive while waiting for linting to complete. It took me a while to figure out what file and combination of rules was causing the behavior and it would be great if others would not have to spend more time only to figure out that they forgot to exclude their build output folder.
The text was updated successfully, but these errors were encountered: