prettier / prettier-vscode

Visual Studio Code extension for Prettier
https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
MIT License
5.03k stars 446 forks source link

Prettier code format take a long time to format #2999

Open ggx-roynguyen opened 12 months ago

ggx-roynguyen commented 12 months ago

Type: Bug

I dont know why but my prettier take about 1-2s to format. image

Extension version: 9.12.0 VS Code version: Code 1.77.3 (Universal) (704ed70d4fd1c6bd6342c436f1ede30d1cff4710, 2023-04-12T09:19:37.325Z) OS version: Darwin arm64 21.4.0 Modes: Sandboxed: Yes

System Info |Item|Value| |---|---| |CPUs|Apple M1 Pro (8 x 24)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|5, 5, 4| |Memory (System)|16.00GB (1.41GB free)| |Process Argv|--crash-reporter-id b70f3c63-e04c-4015-8b63-1803fe3fdfa6| |Screen Reader|no| |VM|0%|
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383cf:30185419 vspor879:30202332 vspor708:30202333 vspor363:30204092 vslsvsres303:30308271 vserr242:30382549 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263cf:30335440 vscoreces:30445986 pythondataviewer:30285071 vscod805cf:30301675 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 cmake_vspar411:30581797 vsaa593:30376534 pythonvs932:30410667 cppdebug:30492333 vsclangdc:30486549 c4g48928:30535728 dsvsc012:30540252 pynewext54:30695312 azure-dev_surveyone:30548225 vsccc:30610678 nodejswelcome1cf:30587006 3biah626:30602489 pyind779:30671433 f6dab269:30613381 pythonsymbol12:30671437 a9j8j154:30646983 vsctsb:30705553 azdwalk:30721579 pythonms35:30701012 pythonfmttextcf:30716743 ```
irlTopper commented 12 months ago

Same. If I use "developer: reload windows", it's perfect again for a little while. But 20 seconds later, saving is slow again.

Sisableng commented 12 months ago

idk, I can't share the results, but I just waited for this for over 30 minutes. i have 16GB of Memory, available 9GB

i tried to disable other extensions, but still slow even i just enable prettier plugin, i hope dev, have solution of this problem

Screenshot (1)

Sisableng commented 12 months ago

finnaly this is the output

Screenshot (2)

roguesherlock commented 12 months ago

I thought I was the only one but I think the recent version is causing the same issues for me

ameer-taghavi commented 12 months ago

same issue for me after updated macOS to 13.3 and updated vs code to the last version

z-verse commented 11 months ago

same issue, after updating plugin to 9.12. macOS 13.2.1, VS Code 1.77.3

beeb commented 11 months ago

Same problem here. Windows 11, using WSL2, and macOS 13.2.1. Latest VSCode

Debug logs don't show errors:

["INFO" - 3:10:57 PM] Formatting file:///home/valentin/[redacted]/src/components/[redacted].astro
["INFO" - 3:10:58 PM] Using config file at '/home/valentin/[redacted]/.prettierrc'
["DEBUG" - 3:10:58 PM] Local prettier module path: '/home/valentin/[redacted]/node_modules/prettier/index.js'
["INFO" - 3:10:58 PM] Using ignore file (if present) at /home/valentin/[redacted]/.prettierignore
["INFO" - 3:10:58 PM] File Info:
{
  "ignored": false,
  "inferredParser": "astro"
}
["INFO" - 3:10:58 PM] Detected local configuration (i.e. .prettierrc or .editorconfig), VS Code configuration will not be used
["INFO" - 3:10:58 PM] Prettier Options:
{
  "filepath": "/home/valentin/[redacted].astro",
  "parser": "astro",
  "useTabs": true,
  "singleQuote": true,
  "trailingComma": "none",
  "printWidth": 120,
  "pluginSearchDirs": [
    "/home/valentin/[redacted]"
  ],
  "semi": false
}
["INFO" - 3:10:58 PM] Formatting completed in 1326ms.

The first line in the logs takes a long time to arrive after hitting the save button.

Sometimes, there is a long waiting time after the first line, and then the extension crashes.

image

A little bissect shows prettier is the culprit:

image

timmeade commented 11 months ago

Same issue here. Mac. i went back one version and it worked great for 1 day now is back slow. just verified still back one version.

This is a MUST fix.

timmeade commented 11 months ago

Same issue here. Mac. i went back one version and it worked great for 1 day now is back slow. just verified still back one version.

This is a MUST fix.

I just set the Default Formatter for the Workspace to prettier. I had it set for the user but the workspace was still unset. It seems to be working again.

TLDR Set the default formatter in BOTH workspace and user settings.

UPDATE: It's back .... Going to have to uninstall this.

ameer-taghavi commented 11 months ago
Screenshot 1402-02-16 at 10 37 50

I unchecked these options and the problem was solved for me!

t0rbik commented 11 months ago

Same issue.

aokigit commented 11 months ago

Same issue here. I'm 🤏 this close to uninstalling cause it's unbearable.

kristinabrueva commented 11 months ago

I got this problem right after adding Jest tests to my NextJs project. Before that it was running and saving files with no issues. Now, the Prettier runs forever and I can't safe my changes unless I press cancel. I had the same problem on a few other projects but this time I noticed that it might be related to tests. Please help!

Screen Shot 2023-05-10 at 16 28 47
beeb commented 11 months ago

I unchecked these options and the problem was solved for me!

@ameer-taghavi doesn't work for me. Still having the issue with those settings disabled.

mrroll commented 11 months ago

~Reverting to v9.10.4 appears to be working for me.~

Edit No it does not.

Terit commented 11 months ago

After trying many of the possible fixes listed in this thread and others in this repo I still ran into this issue. Even after disabling the Prettier extension I ran into the same issues with VS Code's TypeScript formatter.

Eventually I found an issue in the VS Code repo which reported the same issues. I'm happy to report after downgrading to version 1.76.2 and using VS Code heavily for the past 2 days I'm not longer seeing issues with Prettier formatting taking forever to load.

Instructions on how to downgrade and prevent automatic updates from wiping out those changes can be found here.

osilkin98 commented 11 months ago

Is there an ETA on when this will be fixed? This is a pretty breaking bug that I'm surprised doesn't have a higher visibility

lawrence-cruz commented 11 months ago

If you are using Auto Import - ES6, TS, JSX, TSX extension, try to uninstall it and replace it with Auto Import.

image image

https://github.com/prettier/prettier-vscode/issues/1333#issuecomment-905404600

cptSwing commented 11 months ago

After trying many of the possible fixes listed in this thread and others in this repo I still ran into this issue. Even after disabling the Prettier extension I ran into the same issues with VS Code's TypeScript formatter.

Eventually I found an issue in the VS Code repo which reported the same issues. I'm happy to report after downgrading to version 1.76.2 and using VS Code heavily for the past 2 days I'm not longer seeing issues with Prettier formatting taking forever to load.

Instructions on how to downgrade and prevent automatic updates from wiping out those changes can be found here.

For now, this is what worked for me as well!

WagnerMoreira commented 11 months ago

After trying many of the possible fixes listed in this thread and others in this repo I still ran into this issue. Even after disabling the Prettier extension I ran into the same issues with VS Code's TypeScript formatter.

Eventually I found an issue in the VS Code repo which reported the same issues. I'm happy to report after downgrading to version 1.76.2 and using VS Code heavily for the past 2 days I'm not longer seeing issues with Prettier formatting taking forever to load.

Instructions on how to downgrade and prevent automatic updates from wiping out those changes can be found here.

This worked for me 👍

psd-coder commented 11 months ago

The same issue. I do not have installed Auth import plugin. The problem appeared when I updated VS Code to the version above 1.76.2. Fixing VS Code version on 1.76.2 fixes the problem.

hasokeric commented 10 months ago

I am facing the same issue, I am on the Insiders build even.

timmeade commented 10 months ago

I never found it after looking and trying things for days. i have since went back to 1.76.2 per @WagnerMoreira above and have not had the issue since. Just waiting on someone to say they found the root cause before upgrading.

maccman commented 10 months ago

Running into this issue as well. :(

hasokeric commented 10 months ago

I downgraded to 1.76 and the issues went away.

sdsoldi commented 10 months ago

So? The "fix" is downgrade to 1.76?

hasokeric commented 10 months ago

Yes because it looks like no one uses it on a large repo with normal web dev tools, to notice the latest to be slow and they probably dont use Copilot either. Its hard to replicate for anyone, unless they really dont ever work on "real world projects". Its hard to tell, why the whole world isnt screaming "wtf". by the whole world I mean the core maintainers of vscode, prettier, or other plugins like eslint that all have been screwed by Microsofts changes.

Its quite simple to replicate, I can replicate it anytime. If anyone wants to do a Video Conference, let me know.

omer-bar commented 10 months ago

So? The "fix" is downgrade to 1.76?

Didnt work for me, i just use Rome for now... tried all the solutions i could find, still waiting 13-40 seconds for a file to save... if i do 2 saves or cancel the save then it pushes the changes and saves the file without the formatting and sometimes a third save after that is a quick 13ms~ save. so either CTRL+S twice or cancel the save and save again or use something else like Rome.

hasokeric commented 10 months ago

Is this the related issue, finally someone caught it? We should be able to see if it solves it in the next minor releases, perhaps insiders... https://github.com/microsoft/vscode/issues/184926

Sisableng commented 10 months ago

in my case, the problem is prettier-plugin-tailwindcss, i try remove this package, idk but all back to normal without automatically sorting class

caioq commented 10 months ago

This was the solution for me: https://github.com/prettier/prettier-vscode/issues/3044#issuecomment-1613119664

Soviut commented 9 months ago

VSCode 1.80.x which includes the fix for https://github.com/microsoft/vscode/issues/184926 just dropped and seems to have solved the issues.

mpearce-bain commented 9 months ago

VSCode 1.80.x which includes the fix for microsoft/vscode#184926 just dropped and seems to have solved the issues.

Unfortunately the latest version still hasn't resolved the issue for me 😢

Soviut commented 9 months ago

@mpearce-bain Double check that you are on the latest version of VSCode (1.80.1 as if this date). Similarly, make sure the prettier extension is up to date, prettier for tailwind is up to date, etc. If it's still going slowly, try disabling extensions that contribute to formatting.

dmt0 commented 9 months ago

I'm on 1.80.1. All extensions up to date. On large files (2K lines or so) prettier still takes several seconds (15" macbook with i9 CPU, 32GB RAM). I do have a lot of extensions enabled, and I'm sure if I go through all of them I'll find a culprit. I'd assume though that a proper fix implies that I don't have to disable extensions.

Side note: rome works fine, but I don't feel that it's very stable feature-wise - even the formatter part. I'd wait a couple more major version before doing a switch.

dmt0 commented 9 months ago

Found the offending extension. In my case it's Glean. https://github.com/wix-incubator/vscode-glean/issues/157 Once disabled I actually got a performance boost, for all kinds of operations, not just formatting. So perhaps in my case prettier was not a problem at all. 🤷‍♂️

DeedeeSRB commented 8 months ago

For me the fix was to disable the Console Ninja extension. After I disabled and enabled it again, everything seemed to be working just fine.

flexchar commented 6 months ago

After trying many of the possible fixes listed in this thread and others in this repo I still ran into this issue. Even after disabling the Prettier extension I ran into the same issues with VS Code's TypeScript formatter.

Eventually I found an issue in the VS Code repo which reported the same issues. I'm happy to report after downgrading to version 1.76.2 and using VS Code heavily for the past 2 days I'm not longer seeing issues with Prettier formatting taking forever to load.

Instructions on how to downgrade and prevent automatic updates from wiping out those changes can be found here.

Recently tried upgrading to the latest VS Code as of October, 2023. The issue came back creeping from behind with zero hesitation. There must have been some fundamental change in the program. Using Prettier 3 btw.

BVBFD commented 5 months ago

extention_bisect

Using extension bisect get me realize that "Auto Import" extension conflicts with prettier in big sized coding file. So, I recommend others having this issue try to use extension bisect in order to get to know which one is problem.

liuJchun commented 5 months ago

it work for me, see this issue https://github.com/prettier/prettier-vscode/issues/3044

arjunghimire commented 5 months ago

If you are using Auto Import - ES6, TS, JSX, TSX extension, try to uninstall it and replace it with Auto Import.

image image

#1333 (comment)

This is working for me. Great thanks you safe my life bro

bouncingbumble commented 4 months ago

3044 (comment)

thank god, this worked for me

dpw1 commented 3 months ago

In my case the extension "Live Sass Compiler" was the cause of Prettier's slowness. It seems that almost always the reason comes from a conflict from another extension, so I'd suggest disabling them to test it out before installing an older version

github-actions[bot] commented 1 month ago

This issue has been labeled as stale due to inactivity. Reply to keep this issue open.

flexchar commented 1 month ago

Still struggling with this to this day so definitely not stale.

Sent from Proton Mail for iOS

On Tue, Feb 27, 2024 at 02:48, github-actions[bot] @.***(mailto:On Tue, Feb 27, 2024 at 02:48, github-actions[bot] < wrote:

This issue has been labeled as stale due to inactivity. Reply to keep this issue open.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

TenviLi commented 1 month ago

If you are using Auto Import - ES6, TS, JSX, TSX extension, try to uninstall it and replace it with Auto Import.

image image

#1333 (comment)

Thank you for your solution.

TenviLi commented 1 month ago

I've been experiencing an issue where FormatOnSave causes lag and Git becomes unresponsive. I'm running on Windows with the Auto Import extension installed. Disabling Prettier and Auto Import didn't resolve this.

Interestingly, opening a super-long file ignored by .gitignore seems to crash the VSCode Extension Host.

However, since switching to the Windows Subsystem for Linux (WSL), everything has been operating smoothly.

NH-Shohan commented 1 month ago

If you are using Auto Import - ES6, TS, JSX, TSX extension, try to uninstall it and replace it with Auto Import.

image image

#1333 (comment)

This worked for me. I had the same issue. Thank you!

leandroruel commented 5 days ago

prettier is literally killing my WSL2 everytime i format onsave =/