-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[2.4.0][Watch] Creating or renaming files throws errors #1091
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
Comments
renaming a file is a KP - renaming a file wasn't handled, because I assumed that it would trigger similar file system events to creating a file. #1081 Creating a new file has a minor known problem which is a race condition. Below is a rough representation of the events that are triggered:
If (1) happens before (2), then you will receive the parsing error, because typescript does not yet kn
8000
ow about the new file. If the error occurs, then it should be able to be resolved by simply closing and reopening the file. |
Thanks for the explanation! Closing and reopening the file does not solve it, the error remains. Not sure if it helps but I don't recall this being an issue on @typescript-eslint/parser v1.4.2. |
No, this was not a problem in 1.4.2 - we made changes to improve the perf in 2.0.0, which had an adverse effect on the IDE experience. We're in a weird spot as a parser, namely because of these three things:
(1) In v1, we noticed that most users suffered small-huge performance issues because they specified files outside of the project defined by their tsconfig(s). This caused perf problems because typescript would create a new program root and parse the file (and all of its dependencies - i.e. double typechecking many files). To help fix this, in 2.0.0 we started throwing errors for files that weren't included in the project. (2) This change was great for CLI users, however it caused a problem with the IDE use case. ESLint has no concept of a long running, stateful lint session, and just has an API for consumers to call when a file needs to be linted. Typescript is stateful, and has a saved snapshot of the filesystem at the time of the first file parse. Creating a new file, obviously means there is a new file that is not contained within that state. So in 2.4.0 we added file system watchers which attempt to tell typescript to update its representation when a new file is created. (3) As noted however, this process is very much asynchronous, but eslint has no concept of asynchronous parsing, so there is a race condition. I tested this solution in VSCode, with the eslint extension, and it all worked well (https://www.youtube.com/watch?v=0My26ejZJVk). We've got some ideas in the pipeline to attempt to fix this better, but it's a very large problem across many, many teams and pieces, so some of it is bandaids right now. |
Again, thanks for the explanation! If I can help debug or test in any way, more than happy to. |
edited
I did try since i was using the advanced new file plugin for vscode to creates new file, to, as you do in the video, direct create a file (right click -> new file) - but didn't work either. Any specific on the configuration you use in the project on the video? could you share the relevant config part? as for me it's absolutely non working even when closing reopenning the file. |
TL;DR - I relied upon my tests, but my tests didn't cover enough cases. So I think I know what happened.
The problem is that I didn't test my change in vscode again. However, the change I made broke detecting changes in deeply nested folders, because my change from (4) incorrectly interpreted when typescript asks for a directory watcher with This meant that in a real project which has config |
I've just landed #1106, and it will be deployed to the I'd appreciate if you could take a moment to test the canary tag on your codebases, and let me know if anything isn't working as expected for your real-world codebase. |
@bradzacher this looks promising, thanks for taking the time to dig into it! Unfortunately it doesn't fix it for me in Intellij though. I just tried v2.5.0 (released a few hours ago and includes your fix) and the same error is shown when adding and renaming files. In case it helps, the error shows up with about a 3 second delay. Disabling and enabling eslint generally takes a few seconds to take effect so not sure how relevant this is. I'm also occasionally seeing a "Can not get result from language service" error after re-enabling eslint, but this one resolves automatically after a second or two and I can't reliably reproduce it. What can I do to give you more insight? |
I am also still seeing the parser error in VSCode with v2.5.0: Here are my parser options: parserOptions: {
project: "./tsconfig.eslint.json",
tsconfigRootDir: __dirname,
}, And my {
"extends": "./tsconfig.json",
"include": [
"*.js",
"src/**/*",
"scripts/**/*"
]
} I am also using a Yarn workspace if that is relevant. Let me know if there is anything else useful I can provide. |
I don't know what this error message means. I haven't ever used IntelliJ, so I don't know the context in which it would show you this message. I have another fix in #1111 which might help this a bit more. |
Just to note that I've tested with 2.5.1-alpha.0 (the current canary release) and I'm still seeing the same parser error in VSCode, as described elsewhere. For me, this is happening when I create a new file or move an existing file to a new folder. |
Could you please give me some more information about your environment @fiznool? What OS are you using? |
@bradzacher this is a very early stage project, and as such I can probably clone it into a public repo for you to take a look at. I will check and get back to you. Otherwise, I’m using macOS Catalina with stable VSCode. |
I have the same problem on last VSCode issue and Mac OS when creating a new file, this error occurs and I have to restart Vscode to make it update that the file is part of the project. EDIT: Just seeing below but closing and reopening the file fix it. Edit: In fact, closing reopening doesn't work everything |
Please raise a new issue and give as much info as possible. |
Uh oh!
There was an error while loading. Please reload this page.
Original issue tracked in #864
This issue still occurs in Intellij on the latest version 2.4.0 (https://github.com/typescript-eslint/typescript-eslint/releases/tag/v2.4.0) (which includes PR #973). The original reproduction steps apply: Create a new file or rename an existing one and
Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
is thrown:Versions
@typescript-eslint/parser
2.4.0
TypeScript
3.6.4
ESLint
6.5.1
node
11.10.1
The text was updated successfully, but these errors were encountered: