prettier-vscode icon indicating copy to clipboard operation
prettier-vscode copied to clipboard

Prettier code format take a long time to format

Open ggx-roynguyen opened this issue 2 years ago • 71 comments

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

ggx-roynguyen avatar Apr 27 '23 01:04 ggx-roynguyen

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

irlTopper avatar Apr 27 '23 22:04 irlTopper

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 avatar Apr 29 '23 09:04 Sisableng

finnaly this is the output

Screenshot (2)

Sisableng avatar Apr 29 '23 09:04 Sisableng

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

roguesherlock avatar May 01 '23 08:05 roguesherlock

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

ameer-taghavi avatar May 01 '23 08:05 ameer-taghavi

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

z-verse avatar May 02 '23 15:05 z-verse

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

beeb avatar May 03 '23 11:05 beeb

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 avatar May 03 '23 20:05 timmeade

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.

timmeade avatar May 03 '23 21:05 timmeade

Screenshot 1402-02-16 at 10 37 50 I unchecked these options and the problem was solved for me!

ameer-taghavi avatar May 06 '23 07:05 ameer-taghavi

Same issue.

t0rbik avatar May 07 '23 13:05 t0rbik

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

aokigit avatar May 09 '23 01:05 aokigit

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

kristinabrueva avatar May 10 '23 06:05 kristinabrueva

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.

beeb avatar May 10 '23 08:05 beeb

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

Edit No it does not.

mrroll avatar May 11 '23 00:05 mrroll

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.

Terit avatar May 11 '23 15:05 Terit

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

osilkin98 avatar May 13 '23 23:05 osilkin98

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

lawrence-cruz avatar May 15 '23 23:05 lawrence-cruz

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!

cptSwing avatar May 25 '23 11:05 cptSwing

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 👍

WagnerMoreira avatar May 25 '23 21:05 WagnerMoreira

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.

psd-coder avatar May 29 '23 19:05 psd-coder

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

hasokeric avatar Jun 03 '23 18:06 hasokeric

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.

timmeade avatar Jun 03 '23 21:06 timmeade

Running into this issue as well. :(

maccman avatar Jun 04 '23 18:06 maccman

I downgraded to 1.76 and the issues went away.

hasokeric avatar Jun 05 '23 11:06 hasokeric

So? The "fix" is downgrade to 1.76?

sdsoldi avatar Jun 07 '23 11:06 sdsoldi

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.

hasokeric avatar Jun 07 '23 14:06 hasokeric

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.

omer-bar avatar Jun 07 '23 14:06 omer-bar

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

hasokeric avatar Jun 15 '23 17:06 hasokeric

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

Sisableng avatar Jun 16 '23 03:06 Sisableng