-
-
Notifications
You must be signed in to change notification settings - Fork 195
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
Typescript server repetitively "initializing language features" causing high CPU usage in extension v107.2.5 #1963
Comments
Since you said it's not reproducible with a hello world example, could you provide a repository that reproduces this for you? Maybe you can provide a stripped down/anonymous version of your private repository |
After much debugging this morning, I believe I've found a way to reproduce the error.
I also noticed an associated spike in CPU usage that hovers around 15-20% for VS Code even if I'm not interacting with the window at all. If you repeat the exact same steps, but with Svelte for VS Code (v105.22.1), these reloading ts service commands are not triggered repeatedly and there is no associated spike in CPU usage. Instead there is one instance of the following:
|
I can't reproduce it with the vite template. Can you check if the tsconfig.json is constantly getting updated? Checking it In both the current and the version that you think there isn't a bug. In your terminal, use the fs.watch(require.resolve('@tsconfig/svelte/tsconfig.json'), (e) => console.log('@tsconfig/svelte/tsconfig.json', e))
fs.watch('./tsconfig.json', (e) => console.log('./tsconfig.json', e)) |
When using
When trying with the same repo and |
Interesting - so from extension |
Yep, I just tried again with |
I scanned through TypeScript's watch file implementation and our codebase, but I still can't figure out where the file got updated. This might be a weird way to check it. But can you try changing the file permission to delay "write"? This way, when the file is written, an error will be thrown.
|
Thanks for continuing to help follow up on this Jason! I tried explicitly denying write permissions as you mentioned, but it didn't throw any errors in the output channel. I verified that the permissions were indeed changed by trying to manually modify and save the file, which I was prevented from doing. Below I've included more examples of the output. Is there anything else I can provide to try and nail this down?
|
If it weren't being written, maybe something is changing the file's attributes, like permission. https://nodejs.org/api/fs.html#stat-time-values. In that case, the "Modified Time" doesn't change but the "Change Time" changes. But I still have no idea who is doing that. An antivirus software? I think we can skip reloading if "Modified Time" doesn't change. But that wouldn't change the "initializing language features" thing. That's out of our control. We have a different instance of TypeScript language service separate from the TSServer. It'll solve the "Reloading ts service at c:/Users/{your-dir}/vite-project/tsconfig.json due to config updated" problem. And probably the high CPU usage problem since our reloading is less efficient. |
Could it be that due to us and typescript polling for file updates, that this poll is somehow modifying file attributes which triggers the other watcher to think something changed? |
I also suspected that, but I can't reproduce it even when I explicitly set the option to use polling instead of fs event. Also, it seems like all polling file-watch implementations in TypeScript check modified time. https://github.com/microsoft/TypeScript/blob/27d3454f07cb41a24275d7f1de07621b8217f739/src/compiler/sys.ts#L244 This doc explains the possible watch options: fs event doesn't check it, though. It directly forwards the callback to |
Should we try a shot in the blue and replace |
@jasonlyu123 @dummdidumm you are both wizards 🧙🏻 thank you! By switching to the latest 107.3.0 release incorporating your PR (#1973), the repetitive I'm curious, you mentioned that the |
VSCode TypeScript feature controls the |
Describe the bug
When working in a Svelte repository with a TS and Svelte file open, VSCode begins rapidly flashing the
initializing JS/TS language features
notification in the bottom LH bar. I also notice the notification bell in the bottom RH bar flickering on and off with a new notification. This drives high CPU usage and noticeably slows down intellisense in my repo.This behavior doesn't appear to be linked to any user input other than opening both
*.svelte
and*.ts file
s concurrently, and it will continue indefinitely until the VSCode instance is restarted. Running theTypescript: Restart Language Server
command will temporarily halt the behavior, but it resumes within 30s afterward. If TS logging is turned on, the logs will grow indefinitely in size (in one instance I had a 2GB log file in <5 minutes).I'm noticing the following lines appearing over and over in the
Svelte
output tab of my terminal. I am not modifying thetsconfig.json
file at all, so it's odd to me it's detecting an updated config.Would anyone be able to suggest a potential next troubleshooting step?
Troubleshooting Attempts
Reproduction
Open my Svelte directory with both TS & Svelte files in VS Code
hello-world
project , so I'm aware that this could mean there is an issue with my configs. I'm hoping I might be able to get any guidance or suggestions on next troubleshooting steps)Disable all extensions apart from 'Svelte for VS Code'
Open both a
*.svelte
and*.ts
simultaneously in your windowFrustratingly, I can't share my full project directory because it's proprietary, but I have tried to narrow down the issue to a subset of causes. What I have noticed is that the error is reproducible using the latest Svelte for VSCode extention
v107.2.5
, but disapears when using any version prior tov106.0.0
-- even when using the same project directory with no code changes.Expected behaviour
Initializing JS/TS language features
appears once in the status bar and disappears after several secondsSystem Info
Which package is the issue about?
Svelte for VS Code extension
Additional Information, eg. Screenshots
No response
The text was updated successfully, but these errors were encountered: