@@ -35,6 +35,7 @@ import * as ElectronUpdater from "../electron/ElectronUpdater.ts";
3535import * as ElectronWindow from "../electron/ElectronWindow.ts" ;
3636import * as IpcChannels from "../ipc/channels.ts" ;
3737import * as DesktopAppSettings from "../settings/DesktopAppSettings.ts" ;
38+ import * as DesktopSshEnvironment from "../ssh/DesktopSshEnvironment.ts" ;
3839import * as DesktopUpdatePolicy from "./DesktopUpdatePolicy.ts" ;
3940import {
4041 normalizeDesktopUpdateReleaseNotes ,
@@ -369,6 +370,7 @@ function isArm64HostRunningIntelBuild(runtimeInfo: DesktopRuntimeInfo): boolean
369370export const make = Effect . gen ( function * ( ) {
370371 const config = yield * DesktopConfig . DesktopConfig ;
371372 const pool = yield * DesktopBackendPool . DesktopBackendPool ;
373+ const sshEnvironment = yield * DesktopSshEnvironment . DesktopSshEnvironment ;
372374 const desktopState = yield * DesktopState . DesktopState ;
373375 const electronUpdater = yield * ElectronUpdater . ElectronUpdater ;
374376 const electronWindow = yield * ElectronWindow . ElectronWindow ;
@@ -816,17 +818,23 @@ export const make = Effect.gen(function* () {
816818 yield * writeUpdateRestartMarker ;
817819 const { downloadedVersion } = yield * Ref . get ( updateStateRef ) ;
818820 if ( downloadedVersion !== null ) yield * writeInstallRecord ( downloadedVersion ) ;
819- // Stop pooled backends before quitAndInstall can outrun their scope finalizers.
821+ // Stop pooled backends and SSH tunnels before quitAndInstall can outrun their scope finalizers.
820822 const instances = yield * pool . list ;
821823 // stop clears desiredRunning, so retain the recovery set beforehand.
822824 const runningInstances = yield * Effect . filter ( instances , ( instance ) =>
823825 instance . snapshot . pipe ( Effect . map ( ( snapshot ) => snapshot . desiredRunning ) ) ,
824826 ) ;
825827 yield * Ref . set ( installRunningBackendsRef , runningInstances ) ;
826- yield * Effect . forEach (
827- instances ,
828- ( instance ) =>
829- instance . stop ( { timeout : DesktopBackendManager . BACKEND_QUIT_STOP_TIMEOUT } ) ,
828+ yield * Effect . all (
829+ [
830+ Effect . forEach (
831+ instances ,
832+ ( instance ) =>
833+ instance . stop ( { timeout : DesktopBackendManager . BACKEND_QUIT_STOP_TIMEOUT } ) ,
834+ { concurrency : "unbounded" } ,
835+ ) ,
836+ sshEnvironment . closeAllTunnels ,
837+ ] ,
830838 { concurrency : "unbounded" } ,
831839 ) ;
832840 yield * electronUpdater . quitAndInstall ( {
0 commit comments