diff --git a/src/vs/workbench/services/remote/common/remoteExplorerService.ts b/src/vs/workbench/services/remote/common/remoteExplorerService.ts index 7a1052b9368..8743da4d6c8 100644 --- a/src/vs/workbench/services/remote/common/remoteExplorerService.ts +++ b/src/vs/workbench/services/remote/common/remoteExplorerService.ts @@ -743,7 +743,7 @@ export class TunnelModel extends Disposable { async close(host: string, port: number, reason: TunnelCloseReason): Promise { const key = makeAddress(host, port); const oldTunnel = this.forwarded.get(key)!; - if (reason === TunnelCloseReason.AutoForwardEnd) { + if ((reason === TunnelCloseReason.AutoForwardEnd) && oldTunnel && (oldTunnel.source.source === TunnelSource.Auto)) { this.sessionCachedProperties.set(key, { local: oldTunnel.localPort, name: oldTunnel.name,