Repository navigation
Closed
Labels
author-verification-requestedIssues potentially verifiable by issue authorbugIssue identified by VS Code Team member as probable bugelectronIssues and items related to Electronfixed-in-electron-18Issues fixed with Electron 18.x updatefreeze-slow-crash-leakVS Code crashing, performance, freeze and memory leak issuesupstreamIssue identified as 'upstream' component related (exists outside of VS Code)upstream-issue-linkedThis is an upstream issue that has been reported upstreamverifiedVerification succeededwindowsVS Code on Windows issuesworkbench-os-integrationNative OS integration issues
Milestone
Description
Issue Type: Bug
This seems to have already been happening according to #56690 , but collaboration has been limited.
Steps to Reproduce:
- Generate a directory with a lot of files (i.e. 10GB)
- Try to delete it from VsCode
The window freezes and does not allow any action for a while. When it unfreezes, it hasn't really deleted the directory (although it shows as empty in the Explorer).
An easy way to generate such a directory is to build vcpkg ( https://github.com/Microsoft/vcpkg ) and install a large package, then try to delete the buildtrees, downloads, and installed directories.
VS Code version: Code 1.32.3 (a3db5be, 2019-03-14T23:43:35.476Z)
OS version: Windows_NT x64 10.0.17763
System Info
| Item | Value |
|---|---|
| CPUs | Intel(R) Xeon(R) W-2133 CPU @ 3.60GHz (12 x 3600) |
| GPU Status | 2d_canvas: enabled checker_imaging: disabled_off flash_3d: enabled flash_stage3d: enabled flash_stage3d_baseline: enabled gpu_compositing: enabled multiple_raster_threads: enabled_on native_gpu_memory_buffers: disabled_software rasterization: enabled surface_synchronization: enabled_on video_decode: enabled webgl: enabled webgl2: enabled |
| Memory (System) | 31.66GB (24.08GB free) |
| Process Argv | |
| Screen Reader | no |
| VM | 0% |
Metadata
Metadata
Labels
author-verification-requestedIssues potentially verifiable by issue authorbugIssue identified by VS Code Team member as probable bugelectronIssues and items related to Electronfixed-in-electron-18Issues fixed with Electron 18.x updatefreeze-slow-crash-leakVS Code crashing, performance, freeze and memory leak issuesupstreamIssue identified as 'upstream' component related (exists outside of VS Code)upstream-issue-linkedThis is an upstream issue that has been reported upstreamverifiedVerification succeededwindowsVS Code on Windows issuesworkbench-os-integrationNative OS integration issues
Activity
MicahZoltu commentedon Oct 10, 2019
You don't even need a 10GB of files. I have almost never been able to delete
node_modulesfrom a project within VSCode without it hanging. The only time I can delete anode_modulesfolder from VSCode is if there are incredibly few dependencies (like 1-5 dependencies, including transitive).MicahZoltu commentedon Oct 10, 2019
To reproduce, clone just about any real-world Angular project,
npm install, then try to deletenode_modules.bpasero commentedon Oct 17, 2019
Can you follow this wiki and post the results back here to understand more about why performance is so bad for you: https://github.com/Microsoft/vscode/wiki/Performance-Issues
Thanks!
MicahZoltu commentedon Oct 17, 2019
When you first click delete on the large package it spends some time at high CPU (one full core) and high disk IO. Eventually it will prompt you that you need administrator permission. Clicking that results in no meaningful CPU or Disk utilization, yet the entire VSCode UI is locked up. Can't interact with terminal, menus, etc. during this time. Eventually you'll be prompted with
, maybe a few of those depending on how big the folder is (I think it actually has to do with how many files, not actual folder size).
If you keep clicking through the "Keep Waiting" you'll eventually get a UAC prompt. After clicking through the UAC prompt VSCode will go back to high CPU (low disk) but still locked up. You'll receive more "Keep Waiting" prompts during this time and eventually

After clicking delete permanently, disk utilization goes up (though not as high as initially) and the UI becomes responsive finally. If you continue to wait then eventually (no visual feedback) the folder will finish deleting.
All of the above is with extensions disabled. All I did to reproduce on Windosw 10, VSCode 1.39.0 was:
package.json(can be empty)npm install augur-node(random project with a transitive dependency problem)node_modulesin the VSCode file explorer and choose deleteAt step 4 if you instead open Windows file explorer and right-click delete the folder it takes maybe 30 seconds (much faster than VSCode), but there are no lockups along the way and as long as I don't have VSCode open, the delete goes through without problems.
bpasero commentedon Oct 17, 2019
Micah Zoltu (@MicahZoltu) I just tried to reproduce but did not get the dialog. Though I can see a bit of freeze. How is the experience if you Shift+Delete so that you get the "Delete Permanently" directly and not getting asked to move to trash?
MicahZoltu commentedon Oct 18, 2019
Shift+Delete appears to be instant (I didn't know you could shift-delete from within VS Code).
I'm surprised that you are unable to reproduce this issue. I have had it happen to me on all of my (3) devices with VSCode installed, and it happens every time I try to delete a
node_modulesfolder. It has also been a problem for as long as I can remember, and I have seen other people report the same symptoms.Are you running VSCode as admin perhaps? Not that I think it matters, but I am running VSCode from a per-user install, and I have Windows 10 default UAC settings.
bpasero commentedon Oct 18, 2019
Micah Zoltu (@MicahZoltu) so there is a technical difference between
DeleteandShift-Delete:Delete: moves the folder to the windows trash using a Electron API that will call some Windows APIShift+Delete: we do the delete using node.js, bypassing the trashI feel this issue is Electron specific, not VSCode. Are you willing to conduct a small experiment trying to reproduce with Electron alone? This would involve you installing Electron Fiddle (https://electronjs.org/fiddle) and writing a bit of code that triggers the
shell.moveItemToTrashAPI (https://github.com/electron/electron/blob/4-0-x/docs/api/shell.md#shellmoveitemtotrashfullpath) with the path of that large folder.MicahZoltu commentedon Oct 18, 2019
I just tested with Electron Fiddle.
shell.moveItemToTrash('c:/path/to/node_modules')took about 13 seconds, but the Electron Fiddle UI did not lockup during that time.I just tested deletion again with VSCode. This time I didn't get the pop-ups for whatever reason, but the UI did still lock up completely for about 15 seconds.
I would say that the problem here isn't how long it takes to delete the folder (that is an issue with Windows and moving large folders to the trash) but that the deletion occurs on the UI thread and is not an async function call, so if it takes a while to execute it will lock up the UI.
There is an open issue to have Electron make that call async, though it doesn't appear it has much traction at the moment. It sounds like the recommendation currently is to execute that call in a worker thread, rather than in the renderer thread. I would think that moving this call to a worker thread wouldn't be too hard since all you need is a single callback on success, you don't need complex updates along the way. If this were wrapped up nicely it could be turned into an
asyncfunction so the code that calls it just would need to add anawait.MicahZoltu commentedon Oct 18, 2019
FWIW, a quick glance at VSCode suggests that this method is already being called from an
asyncfunction, so someone merely needs to create an async wrapper aroundshell.moveItemToTrashand add anawait. I would hope that doing such a thing is "easy" in Electron, but I have never used it so I don't know how it works or how worker threads work.bpasero commentedon Oct 18, 2019
Micah Zoltu (@MicahZoltu) as far as I can tell, a web worker does not have access to this Electron API, so I see no real solution to this problem. I think Electron itself should move this call onto a separate thread (I think they could do that) and off the renderer. I am not even feeling comfortable calling this method from a different process (e.g. our main process) because it locks for 15s.
The upstream issue is: electron/electron#11555
6 remaining items
[-]VS Code misbehavior when deleting large directories[/-][+]shell.moveItemToTrash() locks the renderer process for large folders[/+]bpasero commentedon May 3, 2021
16baed2#diff-203836ac437fb3e21d1b59c98b79cc6108b7a32153cd673f9553b6c5f562685bR380 adopts Electron 12 async
trashItemmethod.bpasero commentedon May 19, 2021
Can someone verify this that is seeing this using our insider builds? You can give our preview releases a try from: https://code.visualstudio.com/insiders/