Try restoring ports more often

Part of microsoft/vscode-remote-release#4551
This commit is contained in:
Alex Ross
2021-03-12 15:21:10 +01:00
parent d7622d392b
commit 8ca6a56d46

View File

@@ -327,6 +327,7 @@ export class TunnelModel extends Disposable {
public onEnvironmentTunnelsSet: Event<void> = this._onEnvironmentTunnelsSet.event;
private _environmentTunnelsSet: boolean = false;
private configPortsAttributes: PortsAttributes;
private restoreListener: IDisposable | undefined;
private portAttributesProviders: PortAttributesProvider[] = [];
@@ -429,18 +430,19 @@ export class TunnelModel extends Disposable {
await this.forward({ host: tunnel.remoteHost, port: tunnel.remotePort }, tunnel.localPort, tunnel.name, undefined, undefined, tunnel.privacy === TunnelPrivacy.Public);
}
}
} else {
// It's possible that at restore time the value hasn't synced.
const key = await this.getStorageKey();
const listener = this.storageService.onDidChangeValue(async (e) => {
if (e.key === key) {
listener.dispose();
this.tunnelRestoreValue = Promise.resolve(this.storageService.get(await this.getStorageKey(), StorageScope.GLOBAL));
await this.restoreForwarded();
}
});
}
}
if (!this.restoreListener) {
// It's possible that at restore time the value hasn't synced.
const key = await this.getStorageKey();
this.restoreListener = this._register(this.storageService.onDidChangeValue(async (e) => {
if (e.key === key) {
this.tunnelRestoreValue = Promise.resolve(this.storageService.get(await this.getStorageKey(), StorageScope.GLOBAL));
await this.restoreForwarded();
}
}));
}
}
private async storeForwarded() {