prettier / prettier-vscode

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

Prettier code format take a long time to format #2999

Open ggx-roynguyen opened 1 year ago

ggx-roynguyen commented 1 year 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 ```
leandroruel commented 4 months ago

for those facing it with WSL2 what helped me was to increase the amount of RAM to WSL2, just create .wslconfig file in your user folder eg: C:\Users\[YourUserName]:

# Settings apply across all Linux distros running on WSL 2
[wsl2]

# Limits VM memory to use no more than 4 GB, this can be set as whole numbers using GB or MB
memory=4GB 

# Sets the VM to use two virtual processors
processors=2

# Specify a custom Linux kernel to use with your installed distros. The default kernel used can be found at https://github.com/microsoft/WSL2-Linux-Kernel
#kernel=C:\\temp\\myCustomKernel

# Sets additional kernel parameters, in this case enabling older Linux base images such as Centos 6
#kernelCommandLine = vsyscall=emulate

# Sets amount of swap storage space to 8GB, default is 25% of available RAM
swap=8GB

# Sets swapfile path location, default is %USERPROFILE%\AppData\Local\Temp\swap.vhdx
swapfile=C:\\temp\\wsl-swap.vhdx

# Disable page reporting so WSL retains all allocated memory claimed from Windows and releases none back when free
pageReporting=false

# Turn on default connection to bind WSL 2 localhost to Windows localhost. Setting is ignored when networkingMode=mirrored
localhostforwarding=true

# Disables nested virtualization
nestedVirtualization=false

# Turns on output console showing contents of dmesg when opening a WSL 2 distro for debugging
debugConsole=true

# Enable experimental features
[experimental]
sparseVhd=true
gorn commented 3 months ago

I am having this issue and is really annoying to the point that VSCode is unusable (without automatic formatting).

DhanushkaNP commented 2 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 worked for me. Bought a new memory thinking that this was related to a memory issue😅

Silon commented 2 months ago

In my case problem was caused by wrong tailwindcss configuration but most helpful thing can be the way I discovered it. Prettier plugin console didn't show any error but I ran Prettier formatting via cli (prettier --write "**/*.{ts,tsx,md}") and I found importing error in tailwind file. After fix Prettier works as expected

ChenPt commented 4 weeks ago

This was the solution for me: #3044 (comment)这是我的解决方案: #3044 (comment)

It works for me.