-
-
Notifications
You must be signed in to change notification settings - Fork 459
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
FormatOnSave takes a long time #1333
Comments
The issue you referenced was closed because I can’t reproduce the bug. If someone can provide a valid repro I’m happy to try to fix it, but that bug nor this one has enough info. This extension has millions of monthly users. Clearly not everyone is having this issue. Please provide repro step and I’ll investigate. |
This same issue happens when I try to save .md files on VSCode sometimes. But when I cancel and resave the file, it works. |
I was never able to solve this issue and I spent countless hours debugging it over the course of two very frustrating months that it was happening. I eventually realized that I was wasting an absurd amount of time on this one problem and I uninstalled every version of VS Code that I had on my computer. I deleted all the temporary files, cleared the caches, started with a fresh install and reinstalled all of my extensions once again. When I tried to back everything up before taking the nuclear option, the problem just persisted so I realize I had to wipe everything out if I was going to truly fix this. Once I started reinstalling extensions, it became apparent that I have really customized my editor to my liking over the past several months and I thought that I would be able to remember all of the settings that I was using but I couldn't even come close. I ended up having to play with a lot of settings and extensions to get everything to feel normal for me again since I work largely with VueJS. Now I don't have the issue anymore but I was never able to get to the bottom of it and I tried hard. It's the worst kind of bug because you don't get any logs to reference regarding what's happening behind the scenes, other people can't reproduce it because I think it has something to do with your settings (ESLint, Prettier, Vetur, etc...) Save yourself the headache and just make note of the important settings. Go for a fresh install and try to make sure that you don't have too many things which could effect formatting. That's the best solution I could find even after consulting associates and friends for help. Everyone was stumped. |
I agree with @716green , but the truth is that I have done a clean installation and it continues to happen, with only the Prettier extension. |
@ntotten I'm able to mostly consistently repro this,
I'm not sure where the failure is really happening, probably on the first save after line delete and then isn't recovering on the second. This problem happens both with the prettier plugin or the eslint vscode plugin (because we use the prettier plugin for eslint.) The only way I've found to recover from this state is to sigterm the electron thread at 100% load or to restart vscode (at which point, with the replaced fragment close, will continue to format correctly) I suspect this is hard to repro because it probably has more to do with the large number of cascading errors that stems from removing one fragment closure line than removal of the line itself. You probably also need a significantly complicated enough file to trigger the failure mode. |
I have been seeing this over the past couple of days. It has been very frequent and happens even for files that have had a 1 line change. |
seeing it as well. for filesizes as small as 66 lines, probably less too. |
@lsl Thanks for the repo, i will investigate when time allows. |
Seeing this issue also. I observe a few minutes of waiting... |
Same issue here. |
Same issue here |
☝️ |
Had the same problem and solved it by cleaning up my settings.json |
Same issue here |
same issue |
same here |
I experienced this last week on a Typescript React project, however, I also got this problem while working on a Go project just now. Code action on Save took a while and failed to auto format and auto import packages. This is probably an issue with VS Code itself and not the VS Code prettier plugin. I was working in a Workspace with multiple folder paths (3). 2 of which were Go projects and the third being a general data folder which has one |
Same. |
same |
1 similar comment
same |
I'm experiencing this now. I spent about an hour diagnosing it. The issue, in my project, seems related to running typescript w/ nextjs. Perhaps open files, file locks. Not sure. To reproduce the issue, I ran To be clear, this is what I changed
Update: The steps above provided temporarily relief. Increasing system parameters seems to be a better win. I'm on Linux. |
@mgutz I think this might have to do something with having large files open in VSCODE. Whenever I open a compiled version of main js file from Webpack I start to have these issues and its been pretty consistent to the point where I now start to look for the large file that is open a tab somewhere. |
I uninstalled |
For me, it was co-pilot causing it to slow down. I removed it and now its working |
I have not verified this yet (by uninstalling) but I am pretty sure this started happening for me when I installed the ESLint extension. |
I've had same problem. and fixed it. my case was VSCODE "ESLINT" Plugin.. |
There clearly is a problem with the combination but uninstalling one hardly is a fix. Since this is, according to this issue, happening with several other plugins too, I would assume the problem is with prettier and I hope this will be addressed. |
Get a similar issue with jsx and Prettier. Reading the comments, I get the impression that the issue might happen when trying to format incomplete/unrecognized code structures. Changing both the
|
I ran into this issue today and after reading this thread and trying a few combinations, it looks like in my case it was being caused by some sort of interference from the I agree with @udondan, this appears to be an issue with Prettier that is triggered by some sort of conflict with certain onSave behaviors of other plugins. |
Honestly, I could not find the issue with mine at the time of my complaint.
I ended up formatting my entire pc. Thank God I had a backup running. I am
currently using the same extensions I used then, but the format fixed the
error on the spot. It was like a literal head shot to the problem.
…On Mon, Apr 15, 2024 at 9:53 PM movitsky ***@***.***> wrote:
I ran into this issue today and after reading this thread and trying a few
combinations, it looks like in my case it was being caused by some sort of
interference from the colorize plugin. With colorize installed, it was
taking nearly 3.5 minutes to save any file (including, annoyingly, vscode
settings files). Without, saving is now immediate.
I agree with @udondan <https://github.com/udondan>, this appears to be an
issue with Prettier that is triggered by some sort of conflict with certain
onSave behaviors of other plugins.
—
Reply to this email directly, view it on GitHub
<#1333 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AXFYUOFEX2CVZUJ2Y2737UDY5Q44HAVCNFSM4MJTBD32U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMBVG43TQNZVHA3Q>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I have the following config which allows me to fix imports when saving files. I have comments which explain what each one does:
Generally it works really fast on an individual file basis. My problem is when doing a mass find/replace if I'm moving files between libraries, at which point I'll get a pile of "Format of Save" waits. For me the fix is to basically empty codeActionsOnSave before running a big find/replace and then run prettier/eslint manually project-wide, which is much faster. I think one thing that would help here, especially when debugging is to be able to see which code action is problematic and struggling. I assume from all the biome comments that it's either prettier or eslint which get clogged up. |
Thats not a fix but a workaround. Longterm thats not good. But in general this seem to be an issue with vscode not prettiern general then? If i see that everyone has issues but a pretty different setup but the same symthoms. |
If Biom can make it work then I would rather say that Prettier extension is somehow broken. I don’t know if this issue is even recognized by the development team of Prettier, so it is not the best situation if someone wants or must use it in a project. It has been a big disappointment for me personally for months now and this thread is years old. |
If you use "Prettier ESLint" try to disable it and only use "Prettier - Code formatter". This is how I fix mine |
I had this problem with prettier on and off. Then some time ago I switched to biomejs and it worked for a while but now biome does the same thing, it hangs and the file cannot be saved. I can restart vscode and it works for a while and then the problem comes back. Since this happens in both prettier and biome my current take is that something in vscode is causing this, not in the extensions. The below dialog just keeps running forever: |
Just switched to Biome which fixed the problem. Will report back and confirm/deny on @jonaskello's observation. |
Running into this issue again and again. Here are a few things I've noticed:
|
Can confirm this. Biome is a lot better and makes you wait to save a lot less frequently, but it still crops up often. It was perfect for a couple of days. Also @toomuchdesign, disabling/uninstalling that same addon also fixed it for a short time for me too. But now it's back. This is obviously a deeper issue. |
I have similiar behaviour, it almost "comes back" after a while... |
I tried the suggested approaches but couldn't get rid of the issue, I think it might have no exact cause (no right answer for all of us). Think of the recent changes on your machine, I uninstalled I resolved the issue by re-installing the |
Same issue here |
same |
same issue here |
i resolved it by removing one extension from vs code in my case some version of GPT chat -> it was eating my RAMs and completely froze every other extension :D |
Not sure if this helps anyone, but for me the slowness was triggered by I was noticing some slowness and after checking the output logs, it turned out that prettier was running 36+ times on every save (I only use formatOnSave), even for a single whitespace character change. Manual formatting through command palette didn't cause this issue. So after making sure this wasn't caused by my other extensions, I've eventually tracked it down to small change that fixed all my problems. It seems like "editor.formatOnSaveMode": "modificationsIfAvailable", Changing it to "file", prettier now only runs once for each save and things really fast and snappy. "editor.formatOnSaveMode": "file", |
this seem to be the first reasonable proposal since it seem to tacke the problem at the root. |
Summary
Frequently, when I save a file with FormatOnSave option on, it takes forever to finish saving. I have to quit VS Code and restart. Then, save happens instantaneously again. After a while, the issue re-appears. The identical issue to this one: #1253. Not at all clear why that issue is closed -- clearly people are having this problem.
Github Repository to Reproduce Issue
#1253
Steps To Reproduce:
#1253
Expected result
Doesn't take a long time to save.
Actual result
Took forever to save.
Additional information
Obviously, many people are having this same problem. This issue (#1253) should not be closed.
VS Code Version:
Prettier Extension Version:
OS and version:
Prettier Log Output
The text was updated successfully, but these errors were encountered: