microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.01k stars 29.2k forks source link

JS/TS Moving files breaks import relocation #212272

Closed Tordek closed 3 months ago

Tordek commented 5 months ago

Type: Bug

Moving a directory containing multiple JS/TS files to import sometimes breaks.

It always seems to work fine the first time I move a file, but it breaks any following times.

There seems to be a race condition because VSCode is trying to apply the modifications in the old location.

VS Code version: Code 1.89.0 (b58957e67ee1e712cebf466b995adf4c5307b2bd, 2024-05-01T02:09:22.859Z) OS version: Windows_NT x64 10.0.19045 Modes: Remote OS version: Linux x64 5.15.146.1-microsoft-standard-WSL2 Remote OS version: Linux x64 5.15.146.1-microsoft-standard-WSL2 Remote OS version: Linux x64 5.15.146.1-microsoft-standard-WSL2

System Info |Item|Value| |---|---| |CPUs|AMD Ryzen 7 5800X 8-Core Processor (16 x 3793)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|31.91GB (9.67GB free)| |Process Argv|--crash-reporter-id ca91d43f-598e-42ee-8662-02961c5b5089| |Screen Reader|no| |VM|0%| |Item|Value| |---|---| |Remote|WSL: Debian| |OS|Linux x64 5.15.146.1-microsoft-standard-WSL2| |CPUs|AMD Ryzen 7 5800X 8-Core Processor (16 x 3792)| |Memory (System)|15.57GB (12.12GB free)| |VM|0%| |Item|Value| |---|---| |Remote|WSL: Debian| |OS|Linux x64 5.15.146.1-microsoft-standard-WSL2| |CPUs|AMD Ryzen 7 5800X 8-Core Processor (16 x 3792)| |Memory (System)|15.57GB (12.12GB free)| |VM|0%| |Item|Value| |---|---| |Remote|WSL: Debian| |OS|Linux x64 5.15.146.1-microsoft-standard-WSL2| |CPUs|AMD Ryzen 7 5800X 8-Core Processor (16 x 3792)| |Memory (System)|15.57GB (12.12GB free)| |VM|0%|
Extensions (17) Extension|Author (truncated)|Version ---|---|--- language-x86-64-assembly|13x|3.1.4 better-comments|aar|3.0.2 vscode-firefox-debug|fir|2.9.10 dotenv|mik|1.0.1 remote-containers|ms-|0.362.0 remote-wsl|ms-|0.88.2 vim|vsc|1.27.2 vscode-eslint|dba|2.4.4 gitlens|eam|14.9.1 prettier-vscode|esb|10.4.0 vsc-nvm|hen|0.0.3 vscode-kafka|jep|0.15.0 vscode-docker|ms-|1.29.1 makefile-tools|ms-|0.9.10 vscode-jest|Ort|6.2.5 prisma|Pri|5.13.1 vscode-postcss|vun|2.0.2
A/B Experiments ``` vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 vswsl492cf:30256860 vscorecescf:30445987 vscod805cf:30301675 binariesv615:30325510 vsaa593:30376534 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 962ge761:30959799 pythongtdpath:30769146 welcomedialogc:30910334 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30898717 pythontestfixt:30902429 pythonregdiag2:30936856 pyreplss1:30897532 pythonmypyd1:30879173 pythoncet0:30885854 2e7ec940:31000449 pythontbext0:30879054 accentitlementst:30995554 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 dsvsc021:30996838 jg8ic977:31013176 fchga941:31038042 pythonprc:31039816 dwnewjupyter:31039675 ```
mjbvz commented 5 months ago

Please provide specific steps to reproduce the issue

vscodenpa commented 5 months ago

Thanks for creating this issue! We figured it's missing some basic information or in some other way doesn't follow our issue reporting guidelines. Please take the time to review these and update the issue.

Happy Coding!

Tordek commented 5 months ago
  1. Open a project containing submodules, e.g.

    +-index.ts
    + Foo
       + Bar
          + Bar.ts
          + index.ts
  2. Relocate some files (e.g., move the Bar directory up a level).
  3. Move something else.

What should happen: imports in Bar.ts and other files referencing Bar should be updated to the new paths.

What is happening: sometimes, it works; other times, I get an error about Foo/Bar/Bar.ts does not exist. It always seems to work the first time, and failing the second time.

It seems the TS relocate action is attempting to modify the file in its old location, instead of the new one.

vs-code-engineering[bot] commented 3 months ago

Hey @mjbvz, this issue might need further attention.

@Tordek, you can help us out by closing this issue if the problem no longer exists, or adding more information.

Tordek commented 3 months ago

Some update seems to have fixed this.