language-tools
language-tools copied to clipboard
Code linting not updating realtime (Svelte for VS Code)
Describe the bug Svelte for VS Code extension v105.9.0 seems to have introduced a bug with JS/TS scripts which results in linting completely breaking. Errors and warnings are not being updated realtime nor on file save. After a few code changes hover tooltips are showing content for different lines in the document. Snippets and completion are not working properly and are suggesting content for source code that was originally loaded in specific line in the file. Reloading the editor helps only until the code is edited, after which another reload is requred.
To Reproduce
- Install version v105.9.0 of the extension.
- Edit the source code, introduce some errors and check tooltips.
Expected behavior
Screenshots
Window object reference right after a reload:
After changing the window reference to an invalid piece of code, there are no errors, warnings and hints still suggest this is a window object.
After a reload:
Errors/warning basically sit in place(?) Which looks like linting is done only on initial load and then stops.

System:
- OS: Windows 10 21H2 (build 19044.14.15)
- IDE: VSCode 1.63
- Plugin/Package: "Svelte for VSCode",
- Node: v16.10.0
Additional context Linting is only being done once per file and then requires an editor reload - This would suggest why errors "stay in place" after editing the source code.
I can't reproduce this using Windows and the latest Svelte for VS Code extension. Does this only happen on the latest version for you, so if you install a previous version it works? Could you provide the complete code of the file where this occurs in a way that I can copy-paste it?
This issue appears in every file I have tested in basically all my projects, using older VSCode versions doesn not help, I have even gone as far as to reinstalling the editor along with removig all of its files, the only case in which the issue disappears is when using the an older version of the extension.
I can provide you with some source code later this day as I get back to my computer, but I'm not sure if that's gonna help since this problem persists in every other file.
So if an older version of the extension (not an older version of VS Code) does not fix the issue, this sounds like it's unrelated to the extension, although I don't know why it suddenly appeared for you.
Rolling back the extension to a previous version does fix the issue. Sorry if I didn't make it clear.
Ah I see, thanks. Could you
- Add
"svelte.trace.server": "messages"to your settings.json - restart vs code
- go to Ouput(in the terminal area)->Svelte
- Reproduce the issue
- paste the result of that output in here?
This is the entire output after restarting VS Code and reproducing the issue. Haven't compiled the code or anything so this is everything that's happening right after the editor first loads the file and the code was slightly edited to reproduce the issue.
[Trace - 23:43:26] Sending request 'initialize - (0)'.
Initialize language server at file:///c%3A/Users/Shape/Desktop/VSCode/CV
[Trace - 23:43:28] Received response 'initialize - (0)' in 1288ms.
[Trace - 23:43:28] Sending notification 'initialized'.
[Trace - 23:43:28] Sending notification 'workspace/didChangeConfiguration'.
[Trace - 23:43:28] Sending notification 'textDocument/didOpen'.
No svelte.config.js found. Using https://github.com/sveltejs/svelte-preprocess as fallback
Using svelte-preprocess v4.9.8 from c:\Users\Shape\Desktop\VSCode\CV\node_modules\svelte-preprocess
[Trace - 23:43:28] Sending request 'textDocument/codeAction - (1)'.
[Trace - 23:43:28] Sending request 'textDocument/documentColor - (2)'.
[Trace - 23:43:28] Sending request 'textDocument/linkedEditingRange - (3)'.
Initialize new ts service at c:/Users/Shape/Desktop/VSCode/CV/tsconfig.json
Trying to load configs for c:/Users/Shape/Desktop/VSCode/CV
No svelte.config.js found. Using https://github.com/sveltejs/svelte-preprocess as fallback
Using svelte-preprocess v4.9.8 from c:\Users\Shape\Desktop\VSCode\CV\node_modules\svelte-preprocess
[Trace - 23:43:28] Sending notification '$/cancelRequest'.
[Trace - 23:43:28] Sending request 'textDocument/codeAction - (4)'.
[Trace - 23:43:28] Sending request 'textDocument/documentSymbol - (5)'.
SnapshotManager File Statistics:
Project files: 18
Svelte files: 10
From node_modules: 0
Total: 18
[Trace - 23:43:28] Received response 'textDocument/linkedEditingRange - (3)' in 198ms.
[Trace - 23:43:31] Sending notification 'textDocument/didChange'.
[Trace - 23:43:31] Sending notification '$/cancelRequest'.
[Trace - 23:43:31] Sending request 'textDocument/completion - (6)'.
[Trace - 23:43:31] Sending notification 'textDocument/didChange'.
[Trace - 23:43:31] Sending notification 'textDocument/didChange'.
[Trace - 23:43:31] Sending notification 'textDocument/didChange'.
[Trace - 23:43:31] Sending notification 'textDocument/didChange'.
[Trace - 23:43:32] Sending notification 'textDocument/didChange'.
[Trace - 23:43:32] Received response 'textDocument/codeAction - (1)' in 3876ms.
[Trace - 23:43:32] Received response 'textDocument/codeAction - (4)' in 3744ms.
[Trace - 23:43:32] Received response 'textDocument/documentColor - (2)' in 3879ms.
[Trace - 23:43:32] Received response 'textDocument/documentSymbol - (5)' in 3756ms.
Using Svelte v3.44.2 from c:\Users\Shape\Desktop\VSCode\CV\node_modules\svelte\compiler
[Trace - 23:43:32] Sending notification 'textDocument/didChange'.
[Trace - 23:43:32] Sending notification 'textDocument/didChange'.
[Trace - 23:43:32] Sending request 'textDocument/linkedEditingRange - (7)'.
[Trace - 23:43:32] Sending request 'textDocument/codeAction - (8)'.
[Trace - 23:43:32] Sending request 'textDocument/documentColor - (9)'.
Using Svelte v3.44.2 from c:\Users\Shape\Desktop\VSCode\CV\node_modules\svelte\compiler
[Trace - 23:43:33] Received notification 'textDocument/publishDiagnostics'.
[Trace - 23:43:33] Received response 'textDocument/completion - (6)' in 1477ms.
[Trace - 23:43:33] Received response 'textDocument/linkedEditingRange - (7)' in 862ms.
[Trace - 23:43:33] Received response 'textDocument/codeAction - (8)' in 848ms.
[Trace - 23:43:33] Sending request 'textDocument/codeAction - (10)'.
[Trace - 23:43:33] Received response 'textDocument/codeAction - (10)' in 4ms.
Using Svelte v3.44.2 from c:\Users\Shape\Desktop\VSCode\CV\node_modules\svelte\compiler
Using Svelte v3.44.2 from c:\Users\Shape\Desktop\VSCode\CV\node_modules\svelte\compiler
[Trace - 23:43:34] Received notification 'textDocument/publishDiagnostics'.
[Trace - 23:43:34] Received response 'textDocument/documentColor - (9)' in 1623ms.
[Trace - 23:43:34] Sending request 'textDocument/codeAction - (11)'.
[Trace - 23:43:34] Received response 'textDocument/codeAction - (11)' in 4ms.
[Trace - 23:43:37] Sending request 'textDocument/documentSymbol - (12)'.
[Trace - 23:43:38] Received response 'textDocument/documentSymbol - (12)' in 1020ms.
[Trace - 23:43:52] Sending request 'textDocument/hover - (13)'.
[Trace - 23:43:52] Received response 'textDocument/hover - (13)' in 18ms.
[Trace - 23:43:56] Sending request 'textDocument/hover - (14)'.
[Trace - 23:43:56] Received response 'textDocument/hover - (14)' in 60ms.
Very strange, I see nothing suspicious in there.. could you redo the steps above, only with "verbose" instead of "messages" for the trace?
I couldn't see any errors either. I'm starting to think it may be caused by some obscure configuration or conflicts stored deep in system directories I couldn't find? The verbose logs are 75k lines long, here's a link to the file so I won't have to spam it here. https://www.dropbox.com/s/eahcvpa56el1iop/logs-11.01.22.txt?dl=0
This is really super strange. According to the log the diagnostics are published correctly, I see an error about "windowasd" not being defined at the end. So this is either the client side of the extension that is somehow buggy on your end, or VS Code itself trips up somewhere along the way. Maybe this is another hickup of VS Code when installing the extension (#1296 being another example of that). What if you install the extension through downloading it from the website and manually installing it?
Installing the extension directly from a local file did the job. It's strange though, as if VS Code had tripped during the instalation process. But that wouldn't explain why reinstalling it a couple times haven't fixed the issue before. As far as I know installing an addon from within VS Code works similarly, first downloading the file and then extracting it, just ommitting the manual download process.
Anyways, seems like it's something wrong with VS Code handling the installation process and possible errors... I'll diagnose all this on my own since it's probably the editor. Thanks for help and all the time you wasted on something that turned out to be more of an issue of the editor itself. I'll keep you informed if the issue reappears in the future - maybe something got deprecated and so the extension failed to install?
Thanks for confirming that this is not on our part! If you want, you could try to find out if there are files missing when you do the installation from the marketplace and not through the direct download by looking at the content of the vsix file (you can look into it with 7zip for example) and the content of the auto-installed version which should be somewhere in your user folder.
I have the same error in my setup. I'm using the arm64 version of vscode, v: 1.63.2 and v105.10.0 of the Svelte extension. Like @ShapeMess if I introduce errors in a file they are not highlighted before a restart, or if I open tsconfig.json and save that file (that somehow triggers a change as well).
Installing the plugin from a file does not fix it for me, neither does installing an earlier version. I still have to either restart the language server or touch the tsconfig file. I just tried a vanilla vscode with only the Svelte extension to make sure it wasn't caused by other extensions, and I get the same error with just this one extension.
Could you do these steps https://github.com/sveltejs/language-tools/issues/1329#issuecomment-1009374415 and paste the result?
~~@dummdidumm sure thing, will do that now. Just a thought, maybe this could be related to running on an arm mac. I'm having the problem on a M1 Mac and just tried to open this through GitPod (which I think is intel based) and using GitPod there's no problems. Or it could be caused by running macOS? I'm using macOS 12.1 (21C52) - don't know if that could cause problems not sending updates to the plugin after file changes?~~
Doesn't seem to be related to the type of machine, see latest comment.
the output is:
Initialize language server at file:///Users/mellson/Git/playground/appbureauet-svelte
Initialize new ts service at /Users/mellson/Git/playground/appbureauet-svelte/tsconfig.json
Trying to load configs for /Users/mellson/Git/playground/appbureauet-svelte
Loaded config at /Users/mellson/Git/playground/appbureauet-svelte/svelte.config.js
SnapshotManager File Statistics:
Project files: 17
Svelte files: 8
From node_modules: 0
Total: 17
Using Svelte v3.46.2 from /Users/mellson/Git/playground/appbureauet-svelte/node_modules/.pnpm/[email protected]/node_modules/svelte/compiler
Using Svelte v3.46.2 from /Users/mellson/Git/playground/appbureauet-svelte/node_modules/.pnpm/[email protected]/node_modules/svelte/compiler
Using Prettier v2.5.1 from /Users/mellson/.vscode/extensions/svelte.svelte-vscode-105.10.0/node_modules/prettier
Using Prettier v2.5.1 from /Users/mellson/.vscode/extensions/svelte.svelte-vscode-105.10.0/node_modules/prettier
Using Svelte v3.46.2 from /Users/mellson/Git/playground/appbureauet-svelte/node_modules/.pnpm/[email protected]/node_modules/svelte/compiler
Using Svelte v3.46.2 from /Users/mellson/Git/playground/appbureauet-svelte/node_modules/.pnpm/[email protected]/node_modules/svelte/compiler
Using Prettier v2.5.1 from /Users/mellson/.vscode/extensions/svelte.svelte-vscode-105.10.0/node_modules/prettier
Using Prettier v2.5.1 from /Users/mellson/.vscode/extensions/svelte.svelte-vscode-105.10.0/node_modules/prettier
Using Svelte v3.46.2 from /Users/mellson/Git/playground/appbureauet-svelte/node_modules/.pnpm/[email protected]/node_modules/svelte/compiler
Using Svelte v3.46.2 from /Users/mellson/Git/playground/appbureauet-svelte/node_modules/.pnpm/[email protected]/node_modules/svelte/compiler
Nothing looks suspicious there to my eyes. Also when I touch the tsconfig file to make the linting work again nothing changes in the Svelte output window.
~~Update just tried the same project on an intel mac using vscode 1.63.2 (Universal) and v105.10.0 of the Svelte plugin and here there's no problems. And this mac is also running macOS v12.1 (21C52) - so I think this has something to do with vscode on arm macs.~~
Doesn't seem to be related to the type of machine, see latest comment.
Think I found a work around, this seems to be a problem on a file-by-file basis. Once a file has this problem it seems stuck in this mode.
But I found after renaming the file the error goes away. So for now I can rename the file to something else, verify the problem has gone away, and then rename it back to the original name.
Just to finish things off with what I found out since the last time I spoke here. I could not figure out what that issue was caused by for sure, but it seems like it's something specifically with VSCode and/or configuration and not the extension itself, I tried out the insiders version and the issue wasn't showing up. Though I have settings synced between the two, so I don't think it has to do with anything that's easily configurable by the user and more with the underlying configuration. Reinstalling the extension from within VSCode's builtin extensions tab brought the bug back to life on the release version.
I had a similar problem... in my case it was a simple Linting issue with Typescript:
Wrong:
// Object "createNewRef" is possibly 'undefined'.
createNewRef.focus();
easy Fix:
createNewRef?.focus();
However, every time I resolved such issues, I had to restart the Svelte language server to see that the issue was solved. The issues would not disappear without restarting the language server.
To be able to use linting in real-time, I had to switch versions.
The latest Version without this problem is currently: v105.21.0
So the latest version of the extension has this issue for you?
Jup, I had this issue in 105.22.0 and 105.22.1
I can confirm the problem on v105.22.1 - The extension is unsuable for me in this state, since linting breaks almost every 5 seconds and I have to restart the language server to get any intellisense working.
If I just downgrade to v105.21.0 via the VSCode Extension Option, the error is still there (even after restarting VS Code), but if I uninstall the extension and install v105.21.0 from VSIX the error is fixed.
I will just add that switching to a respective VS Code Insiders version literally always fixed the issue for me. So far this has only happened to me in the regular version and I've been using regular/insiders interchangebly. Not sure what others have experienced in that context.
Can you check if the output channel logged any errors? It's near the integrated terminal. Chose "svelte" in the dropdown at the top right corner of it. Wondering if typescript 4.8 changes something causing an error.
If there isn't, you might have to provide a reproduction. Otherwise, we can't do anything about it.
@jasonlyu123 I don't currently have this issue. It appears and disappears every now and then. I just wanted to point out that insiders haven't given me any issues related to that topic, and that's for a few good months.
The log shows only the following error:
Using Svelte v3.48.0 from c:\Workspace\svelteTest\my-app\node_modules\svelte\compiler
Parsing c:/Workspace/svelteTest/my-app/src/Overview.svelte failed. No preprocess config found but lang tag exists. Skip
showing error because they likely use other preprocessors.
This error does not show up with a clean installation of v105.21.0
Here is also the added log with tracing enabled. But this seems to be the only error:
Using Svelte v3.48.0 from c:\Workspace\svelteTest\my-app\node_modules\svelte\compiler
Using Svelte v3.48.0 from c:\Workspace\svelteTest\my-app\node_modules\svelte\compiler
Parsing c:/Workspace/svelteTest/my-app/src/Overview.svelte failed. No preprocess config found but lang tag exists. Skip showing error because they likely use other preprocessors.
[Trace - 13:52:43] Received notification 'textDocument/publishDiagnostics'.
[Trace - 13:52:43] Sending request 'textDocument/semanticTokens/full - (18)'.
[Trace - 13:52:44] Sending request 'textDocument/codeAction - (19)'.
[Trace - 13:52:44] Received response 'textDocument/codeAction - (19)' in 4ms.
[Trace - 13:52:44] Received response 'textDocument/semanticTokens/full - (18)' in 1019ms.
[Trace - 13:52:45] Sending notification 'textDocument/didChange'.
[Trace - 13:52:45] Sending notification 'textDocument/didChange'.
[Trace - 13:52:45] Sending notification 'textDocument/didChange'.
[Trace - 13:52:45] Sending request 'textDocument/codeAction - (20)'.
[Trace - 13:52:45] Received response 'textDocument/codeAction - (20)' in 33ms.
[Trace - 13:52:46] Sending request 'textDocument/documentColor - (21)'.
[Trace - 13:52:46] Sending request 'textDocument/codeAction - (22)'.
[Trace - 13:52:46] Received response 'textDocument/codeAction - (22)' in 3ms.
Using Svelte v3.48.0 from c:\Workspace\svelteTest\my-app\node_modules\svelte\compiler
Using Svelte v3.48.0 from c:\Workspace\svelteTest\my-app\node_modules\svelte\compiler
Parsing c:/Workspace/svelteTest/my-app/src/Overview.svelte failed. No preprocess config found but lang tag exists. Skip showing error because they likely use other preprocessors.
[Trace - 13:52:46] Received notification 'textDocument/publishDiagnostics'.
[Trace - 13:52:46] Sending request 'textDocument/codeAction - (23)'.
[Trace - 13:52:46] Received response 'textDocument/codeAction - (23)' in 2ms.
[Trace - 13:52:47] Sending request 'textDocument/semanticTokens/full - (24)'.
[Trace - 13:52:47] Received response 'textDocument/documentColor - (21)' in 1008ms.
[Trace - 13:52:47] Sending request 'textDocument/codeAction - (25)'.
[Trace - 13:52:47] Received response 'textDocument/codeAction - (25)' in 2ms.
[Trace - 13:52:47] Sending notification 'textDocument/didChange'.
[Trace - 13:52:48] Sending notification 'textDocument/didChange'.
[Trace - 13:52:48] Sending notification 'textDocument/didChange'.
[Trace - 13:52:48] Sending request 'textDocument/completion - (26)'.
[Trace - 13:52:48] Received response 'textDocument/completion - (26)' in 23ms.
[Trace - 13:52:48] Sending request 'html/tag - (27)'.
[Trace - 13:52:48] Received response 'html/tag - (27)' in 1ms.
[Trace - 13:52:48] Sending request 'textDocument/codeAction - (28)'.
[Trace - 13:52:48] Received response 'textDocument/codeAction - (28)' in 6ms.
Using Svelte v3.48.0 from c:\Workspace\svelteTest\my-app\node_modules\svelte\compiler
Using Svelte v3.48.0 from c:\Workspace\svelteTest\my-app\node_modules\svelte\compiler
[Trace - 13:52:49] Received notification 'textDocument/publishDiagnostics'.
[Trace - 13:52:49] Sending request 'textDocument/codeAction - (29)'.
[Trace - 13:52:49] Received response 'textDocument/codeAction - (29)' in 2ms.
[Trace - 13:52:50] Received response 'textDocument/semanticTokens/full - (24)' in 3066ms.
[Trace - 13:52:50] Sending request 'textDocument/documentColor - (30)'.
[Trace - 13:52:51] Received response 'textDocument/documentColor - (30)' in 1014ms.
[Trace - 13:52:52] Sending request 'textDocument/semanticTokens/full - (31)'.
[Trace - 13:52:52] Sending request 'textDocument/documentSymbol - (32)'.
[Trace - 13:52:53] Received response 'textDocument/semanticTokens/full - (31)' in 1011ms.
[Trace - 13:52:53] Received response 'textDocument/documentSymbol - (32)' in 1022ms.
That "skipping" log is expected and unrelated to OP's problem. We now hide the parser error if you didn't properly set up a svelte.config.js and we detect a lang attribute. You can follow the docs to set up a svelte.config.js.
What do you mean by intellisense? It's just the diagnostics? Or there are other features not working?
That "skipping" log is expected and unrelated to OP's problem. We now hide the parser error if you didn't properly set up a
svelte.config.jsand we detect a lang attribute. You can follow the docs to set up a svelte.config.js.What do you mean by intellisense? It's just the diagnostics? Or there are other features not working?
Hi! The interesting thing is - this "skipping" error only appears with the newer version, not with the old version, when I perform the exact same change on the same file.
What stops working: Syntax highlighting seems to freeze, the colors do no longer match the word boundaries, code errors are also reported at the wrong position, even when fixed. It seems that everything related to parsing the code freezes at a certain state of the file and new changes are completely ignored. As soon as I restart the language server everything is working again and the wrong errors/highlighting are again in sync, but only for a few seconds.