Skip to content

Terminate COM surrogate process before update/gc#313791

Merged
dmitrivMS merged 10 commits intomainfrom
dev/dmitriv/update-com-surrogate-fix
May 6, 2026
Merged

Terminate COM surrogate process before update/gc#313791
dmitrivMS merged 10 commits intomainfrom
dev/dmitriv/update-com-surrogate-fix

Conversation

@dmitrivMS
Copy link
Copy Markdown
Contributor

@dmitrivMS dmitrivMS commented May 1, 2026

Fixes #294546
Fixes #295844
Fixes #312098
Fixes #290467
Fixes #313585

The fix for the mutex race is necessary since under locking conditions uninstall of AppX package may take some time and we are restarting the app by that time, but setup is still running.

I was able to repro this on 1.118.1 with FreeCommander XE 32-bit.
Verified the fix with both user and system setup/update.

Co-authored-by: Copilot copilot@github.com

Co-authored-by: Copilot <copilot@github.com>
Copilot AI review requested due to automatic review settings May 1, 2026 20:30
@dmitrivMS dmitrivMS added the install-update VS Code installation and upgrade system issues label May 1, 2026
@dmitrivMS dmitrivMS self-assigned this May 1, 2026
@dmitrivMS dmitrivMS requested a review from deepak1556 May 1, 2026 20:30
@dmitrivMS
Copy link
Copy Markdown
Contributor Author

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Addresses Windows update runs that never complete by proactively terminating the File Explorer context-menu COM surrogate (dllhost.exe /Processid:<CLSID>) that can hold file handles and block inno_updater --gc cleanup (issue #294546).

Changes:

  • Add a Win32 update-service step to stop the context-menu COM surrogate before invoking inno_updater --gc.
  • Add an Inno Setup helper to stop the same COM surrogate before AppX removal and before --gc cleanup.
  • Introduce win32ContextMenu product configuration and wire its CLSID into the Win32 setup build definitions.
Show a summary per file
File Description
src/vs/platform/update/electron-main/updateService.win32.ts Runs a PowerShell-based kill step for the context-menu COM surrogate before background-update GC.
src/vs/base/common/product.ts Adds win32ContextMenu to product configuration typing.
build/win32/code.iss Adds KillContextMenuComSurrogate() and invokes it prior to AppX removal and GC.
build/gulpfile.vscode.win32.ts Passes FileExplorerContextMenuCLSID define to Inno Setup when available from product metadata.

Copilot's findings

Comments suppressed due to low confidence (1)

src/vs/platform/update/electron-main/updateService.win32.ts:206

  • The exit handler logs at info level regardless of whether PowerShell succeeded. If code is non-zero, this should be treated as a failure (warn/error) so we don’t silently miss the cleanup step; conversely a 0 exit could be logged at trace to reduce log noise.
				}).once('exit', code => {
					this.logService.info(`update#killContextMenuComSurrogate: powershell exited with code ${code}`);
					resolve();
  • Files reviewed: 4/4 changed files
  • Comments generated: 2

Comment thread build/win32/code.iss
Comment thread src/vs/platform/update/electron-main/updateService.win32.ts Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 5/5 changed files
  • Comments generated: 2

Comment thread src/vs/code/electron-main/main.ts Outdated
Comment thread src/vs/platform/update/electron-main/updateService.win32.ts
@dmitrivMS dmitrivMS added the windows VS Code on Windows issues label May 2, 2026
@dmitrivMS
Copy link
Copy Markdown
Contributor Author

@dmitrivMS dmitrivMS enabled auto-merge (squash) May 2, 2026 07:46
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Screenshot Changes

Base: 88fa3d91 Current: 2ee3ea4c

Changed (26)

chat/input/chatInput/Default/Dark
Before After
before after
chat/input/chatInput/Default/Light
Before After
before after
chat/input/chatInput/WithFileChanges/Dark
Before After
before after
chat/input/chatInput/WithFileChanges/Light
Before After
before after
chat/input/chatInput/WithTodos/Dark
Before After
before after
chat/input/chatInput/WithTodos/Light
Before After
before after
chat/input/chatInput/WithTodosAndFileChanges/Light
Before After
before after
chat/input/chatInput/WithArtifactsAndFileChanges/Dark
Before After
before after
chat/input/chatInput/WithArtifactsAndFileChanges/Light
Before After
before after
chat/input/chatInput/Full/Dark
Before After
before after
chat/input/chatInput/Full/Light
Before After
before after
chat/widget/chatWidget/PendingToolApproval/Dark
Before After
before after
chat/widget/chatWidget/PendingToolApproval/Light
Before After
before after
chat/widget/chatWidget/MultiTurn/Light
Before After
before after
agentSessionsViewer/CompletedRead/Dark
Before After
before after
agentSessionsViewer/CompletedRead/Light
Before After
before after
agentSessionsViewer/FailedWithoutDuration/Dark
Before After
before after
agentSessionsViewer/FailedWithoutDuration/Light
Before After
before after
agentSessionsViewer/WithFileChangesList/Dark
Before After
before after
agentSessionsViewer/WithFileChangesList/Light
Before After
before after
agentSessionsViewer/WithBadgeAndDiff/Dark
Before After
before after
agentSessionsViewer/WithBadgeAndDiff/Light
Before After
before after
agentSessionsViewer/BackgroundProvider/Dark
Before After
before after
agentSessionsViewer/BackgroundProvider/Light
Before After
before after
agentSessionsViewer/ClaudeProvider/Dark
Before After
before after
agentSessionsViewer/ClaudeProvider/Light
Before After
before after

Copy link
Copy Markdown
Collaborator

@deepak1556 deepak1556 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we just run this at RemoveAppxPackage which is more definitive point in time where we want the old appx package to be removed, this step always runs during update flow. I don't see why we also need to call it before gc.

@dmitrivMS dmitrivMS merged commit c2a4260 into main May 6, 2026
26 checks passed
@dmitrivMS dmitrivMS deleted the dev/dmitriv/update-com-surrogate-fix branch May 6, 2026 22:42
@vs-code-engineering vs-code-engineering Bot added this to the 1.120.0 milestone May 6, 2026
@dmitrivMS
Copy link
Copy Markdown
Contributor Author

Could we just run this at RemoveAppxPackage which is more definitive point in time where we want the old appx package to be removed, this step always runs during update flow. I don't see why we also need to call it before gc.

For background update for a user setup we run --gc from from UpdateService - by that time the file can be locked again. There are other scenarios and even when we do and there is a wait, the file can be locked again - so we would be blocked.

@deepak1556
Copy link
Copy Markdown
Collaborator

by that time the file can be locked again.

Why would that be, we have unregistered the appx corresponding to the old version if anything is running at the time of gc it should be from the new version which gc will not even touch in the first place. Could you share steps that demonstrate the issue of old dll holding up process after removing the appx package ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

install-update VS Code installation and upgrade system issues windows VS Code on Windows issues

Projects

None yet

4 participants