microsoft / vscode

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

VS Code tried to update itself and deleted `resources/app/out`; no longer starts and broke my existing open sessions #224571

Open sandersaares opened 1 month ago

sandersaares commented 1 month ago

Does this issue occur when all extensions are disabled?: Unknown

Version: 1.91.1 (system setup) Commit: f1e16e1e6214d7c44d078b1f0607b2388f29d729 Date: 2024-07-09T22:06:49.809Z Electron: 29.4.0 ElectronBuildId: 9728852 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Windows_NT x64 10.0.22631

Steps to Reproduce:

  1. Wait for a VS Code update to be automatically installed at 12:00 on an arbitrary day (I do not know how/why/when exactly this occurs).
  2. Observe that any open VS Code window suddenly becomes nonfunctional - many button presses do nothing, tasks fail to launch.
  3. Observe that VS Code logs (e.g. user settings sync log) complain about missing .js files.
  4. Observe that starting new VS Code instances fails with the below error message.
Error: Cannot find module 'C:\Program Files\Microsoft VS Code\resources\app\out\main'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1055:15)
    at s._resolveFilename (node:electron/js2c/browser_init:2:115690)
    at node:electron/js2c/browser_init:2:121111
    at node:electron/js2c/browser_init:2:121360
    at node:electron/js2c/browser_init:2:121364
    at BuiltinModule.compileForInternalLoader (node:internal/bootstrap/realm:392:7)
    at BuiltinModule.compileForPublicLoader (node:internal/bootstrap/realm:328:10)
    at loadBuiltinModule (node:internal/modules/helpers:68:7)
    at Module._load (node:internal/modules/cjs/loader:923:17)
    at c._load (node:electron/js2c/node_init:2:13672)

Has happened twice so far (last time about a month ago, presumably with previous update).

VS code main.log has the following on recent startup before the event:

2024-08-02 07:04:09.468 [info] update#setState idle
2024-08-02 07:04:39.476 [info] update#setState checking for updates
2024-08-02 07:04:39.480 [info] update#setState downloading
2024-08-02 07:04:39.481 [info] update#setState downloaded 

The Application event log has some RestartManager entries at the time when the problem started:

  1. Starting session 0 - ‎2024‎-‎08‎-‎02T09:00:39.339256800Z.
  2. Application 'C:\Program Files\Microsoft VS Code\Code.exe' (pid 8852) cannot be restarted - Application SID does not match Conductor SID.. (repeated with different PIDs)
  3. Machine restart is required.
  4. Ending session 0 started ‎2024‎-‎08‎-‎02T09:00:39.339256800Z.

Next to the vanished resources/app/out directory is a directory resources/app/node_modules.asar.unpacked whose timestamp matches the event in the Application event log.

I surmise that VS Code tried to update itself but somehow messed up and left me with a broken installation. I will reinstall since I need to continue my work but I have made copies of relevant folders in case there may be something valuable in there (I was not able to find any other relevant logs, though).

sandersaares commented 1 month ago

Happened again just 2 minutes ago, again at local noon 12:00 exactly.

jepio commented 1 month ago

Same here - but I only experience this in Dev Box.

Abe27342 commented 3 days ago

I encounter this relatively regularly on my machine. I have VS Code installed at the system level to leverage it on multiple profiles (personal, work).

Perhaps some hits of this issue are related to system-level installations requiring elevation to update, which is documented here? I have never seen the elevation prompt mentioned:

The in-product update flow will also require elevation, making it less streamlined than the user setup. On the other hand, installing VS Code using the system setup means that it will be available to all users in the system.

before encountering this issue.

If there's any diagnostics/settings I can enable to help improve the experience here, please let me know.