Fix double update issue on Windows#292746
Conversation
There was a problem hiding this comment.
Pull request overview
This change adjusts the Windows update feed construction so that, when a specific pending commit is being overwritten, the update check can be targeted at that pending commit instead of always using the currently installed commit. This supports the overwrite/update machinery needed to avoid scenarios where a user effectively has to restart twice to land on the latest Insiders build.
Changes:
- Extend
Win32UpdateService.doCheckForUpdatesto accept an optionalpendingCommitparameter. - Use
pendingCommit ?? this.productService.commit!when building the Windows update feed URL so that, if a pending update commit is known, the server is queried as if that pending commit were the current version.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (2)
src/vs/platform/update/electron-main/updateService.win32.ts:272
- When restoring the Ready state after an Overwriting check fails, the
explicitparameter passed to State.Ready should be the original explicit value from when the update was first Ready, not the explicit parameter from the current doCheckForUpdates call. The current explicit parameter represents whether the overwrite check was explicit, not whether the original update check was explicit. This should usethis.state.explicitto preserve the original state.
this.setState(State.Ready(this.state.update, explicit, false));
src/vs/platform/update/electron-main/updateService.win32.ts:272
- When restoring the Ready state after an Overwriting check fails, the instance variable
this._overwriteshould be reset to false to match the overwrite flag in the state. Without this, subsequent state transitions may incorrectly usethis._overwrite = trueeven though we're no longer in an overwrite scenario.
// If we were checking for an overwrite update and it failed,
// restore the Ready state with the pending update
if (this.state.type === StateType.Overwriting) {
this.setState(State.Ready(this.state.update, explicit, false));
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
src/vs/platform/update/electron-main/updateService.win32.ts:381
- The optional chaining
this.availableUpdate?.updateProcess?.once('exit', ...)on line 380 could resolve to undefined, causing the Promise.race to wait indefinitely. This could happen ifthis.availableUpdateorthis.availableUpdate.updateProcessbecomes undefined between line 377 (where pid is captured) and line 380. While unlikely due to the synchronous execution, if the method is called concurrently or if there's a race with another part of the code clearing availableUpdate, this could cause the timeout to always be hit.
A safer approach would be to capture the updateProcess reference at the start of the method (alongside availableUpdate), ensuring the same object is used throughout the cancellation logic.
new Promise<boolean>(resolve => this.availableUpdate?.updateProcess?.once('exit', () => resolve(true))),
timeout(30 * 1000).then(() => false)
Fixes #268531