@@ -746,12 +746,12 @@ index fdd5890c69f72025b94913380f0d226226e8c8fb..e084236526b38c1144d47b8b3000b367
746
746
(err: any, socket: ISocket | undefined) => {
747
747
if (err || !socket) {
748
748
options.logService.error(`${logPrefix} socketFactory.connect() failed. Error:`);
749
- @@ -331,12 +331,17 @@ export const enum PersistentConnectionEventType {
749
+ @@ -331,12 +331,16 @@ export const enum PersistentConnectionEventType {
750
750
}
751
751
export class ConnectionLostEvent {
752
752
public readonly type = PersistentConnectionEventType.ConnectionLost;
753
753
+ constructor(
754
- + public readonly suppressPopup ?: boolean
754
+ + public readonly connectionAttempt ?: number
755
755
+ ) { }
756
756
}
757
757
export class ReconnectionWaitEvent {
@@ -760,67 +760,68 @@ index fdd5890c69f72025b94913380f0d226226e8c8fb..e084236526b38c1144d47b8b3000b367
760
760
public readonly durationSeconds: number,
761
761
- private readonly cancellableTimer: CancelablePromise<void>
762
762
+ private readonly cancellableTimer: CancelablePromise<void>,
763
- + public readonly suppressPopup?: boolean,
764
- + public readonly forceDialog?: boolean
763
+ + public readonly connectionAttempt?: number,
765
764
) { }
766
765
767
766
public skipWait(): void {
768
- @@ -345,12 +350 ,21 @@ export class ReconnectionWaitEvent {
767
+ @@ -345,12 +349 ,21 @@ export class ReconnectionWaitEvent {
769
768
}
770
769
export class ReconnectionRunningEvent {
771
770
public readonly type = PersistentConnectionEventType.ReconnectionRunning;
772
771
+ constructor(
773
- + public readonly suppressPopup ?: boolean
772
+ + public readonly connectionAttempt ?: number
774
773
+ ) { }
775
774
}
776
775
export class ConnectionGainEvent {
777
776
public readonly type = PersistentConnectionEventType.ConnectionGain;
778
777
+ constructor(
779
- + public readonly suppressPopup ?: boolean
778
+ + public readonly connectionAttempt ?: number
780
779
+ ) { }
781
780
}
782
781
export class ReconnectionPermanentFailureEvent {
783
782
public readonly type = PersistentConnectionEventType.ReconnectionPermanentFailure;
784
783
+ constructor(
785
- + public readonly suppressPopup ?: boolean | undefined
784
+ + public readonly connectionAttempt ?: number
786
785
+ ) { }
787
786
}
788
787
export type PersistenConnectionEvent = ConnectionGainEvent | ConnectionLostEvent | ReconnectionWaitEvent | ReconnectionRunningEvent | ReconnectionPermanentFailureEvent;
789
788
790
- @@ -411,16 +425,22 @@ abstract class PersistentConnection extends Disposable {
789
+ @@ -411,8 +424,9 @@ abstract class PersistentConnection extends Disposable {
791
790
}
792
791
const logPrefix = commonLogPrefix(this._connectionType, this.reconnectionToken, true);
793
792
this._options.logService.info(`${logPrefix} starting reconnecting loop. You can get more information with the trace log level.`);
794
793
- this._onDidStateChange.fire(new ConnectionLostEvent());
795
- + let suppressPopup = true;
796
- + let forceDialog = false;
797
- + this._onDidStateChange.fire(new ConnectionLostEvent(suppressPopup));
794
+ + this._onDidStateChange.fire(new ConnectionLostEvent(0));
798
795
const TIMES = [5, 5, 10, 10, 10, 10, 10, 30];
799
- + const SHOW_POPUP_ON_ATTEMPT = 2 // aka third attempt
800
796
+
801
797
const disconnectStartTime = Date.now();
802
798
let attempt = -1;
803
799
do {
804
- attempt++;
805
- + suppressPopup = (attempt < SHOW_POPUP_ON_ATTEMPT) ? true : false
806
- + forceDialog = (attempt == SHOW_POPUP_ON_ATTEMPT)
800
+ @@ -420,7 +434,7 @@ abstract class PersistentConnection extends Disposable {
807
801
const waitTime = (attempt < TIMES.length ? TIMES[attempt] : TIMES[TIMES.length - 1]);
808
802
try {
809
803
const sleepPromise = sleep(waitTime);
810
804
- this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise));
811
- + this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise, suppressPopup, forceDialog ));
805
+ + this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise, attempt ));
812
806
813
807
this._options.logService.info(`${logPrefix} waiting for ${waitTime} seconds before reconnecting...`);
814
808
try {
815
- @@ -433,7 +453,7 @@ abstract class PersistentConnection extends Disposable {
809
+ @@ -433,13 +447,13 @@ abstract class PersistentConnection extends Disposable {
816
810
}
817
811
818
812
// connection was lost, let's try to re-establish it
819
813
- this._onDidStateChange.fire(new ReconnectionRunningEvent());
820
- + this._onDidStateChange.fire(new ReconnectionRunningEvent(suppressPopup ));
814
+ + this._onDidStateChange.fire(new ReconnectionRunningEvent(attempt ));
821
815
this._options.logService.info(`${logPrefix} resolving connection...`);
822
816
const simpleOptions = await resolveConnectionOptions(this._options, this.reconnectionToken, this.protocol);
823
817
this._options.logService.info(`${logPrefix} connecting to ${simpleOptions.host}:${simpleOptions.port}...`);
818
+ await connectWithTimeLimit(simpleOptions.logService, this._reconnect(simpleOptions), RECONNECT_TIMEOUT);
819
+ this._options.logService.info(`${logPrefix} reconnected!`);
820
+ - this._onDidStateChange.fire(new ConnectionGainEvent());
821
+ + this._onDidStateChange.fire(new ConnectionGainEvent(attempt));
822
+
823
+ break;
824
+ } catch (err) {
824
825
diff --git a/src/vs/platform/storage/browser/storageService.ts b/src/vs/platform/storage/browser/storageService.ts
825
826
index ab3fd347b69f8a3d9b96e706cd87c911b8ffed6b..9d351037b577f9f1edfd18ae9b3c48a211f4467f 100644
826
827
--- a/src/vs/platform/storage/browser/storageService.ts
@@ -3951,16 +3952,28 @@ index 94e7e7a4bac154c45078a1b5034e50634a7a43af..8164200dcef1efbc65b50eef9c270af3
3951
3952
this._dirnameKey.set(value ? dirname(value).fsPath : null);
3952
3953
this._pathKey.set(value ? value.fsPath : null);
3953
3954
diff --git a/src/vs/workbench/contrib/remote/browser/remote.ts b/src/vs/workbench/contrib/remote/browser/remote.ts
3954
- index 98573a206f14928fc3fdf18fe927cb75034e4ad1..a031f76924abf8f10c510ea9c043f670c5b43074 100644
3955
+ index 98573a206f14928fc3fdf18fe927cb75034e4ad1..1430666aa94f941bda086df503fec8b35aa2b25f 100644
3955
3956
--- a/src/vs/workbench/contrib/remote/browser/remote.ts
3956
3957
+++ b/src/vs/workbench/contrib/remote/browser/remote.ts
3957
- @@ -795,31 +795,43 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution {
3958
+ @@ -730,6 +730,7 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution {
3959
+ @IContextKeyService contextKeyService: IContextKeyService
3960
+ ) {
3961
+ const connection = remoteAgentService.getConnection();
3962
+ + const SHOW_POPUP_ON_ATTEMPT = 2 // aka third attempt
3963
+ if (connection) {
3964
+ let visibleProgress: VisibleProgress | null = null;
3965
+ let lastLocation: ProgressLocation.Dialog | ProgressLocation.Notification | null = null;
3966
+ @@ -793,33 +794,47 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution {
3967
+ disposableListener.dispose();
3968
+ disposableListener = null;
3958
3969
}
3970
+ + let suppressPopup = (typeof e.connectionAttempt == 'number' && e.connectionAttempt < SHOW_POPUP_ON_ATTEMPT)
3971
+ + let forceDialog = (typeof e.connectionAttempt == 'number' && e.connectionAttempt == SHOW_POPUP_ON_ATTEMPT)
3959
3972
switch (e.type) {
3960
3973
case PersistentConnectionEventType.ConnectionLost:
3961
3974
- if (!visibleProgress) {
3962
3975
- visibleProgress = showProgress(ProgressLocation.Dialog, [reconnectButton, reloadButton]);
3963
- + if (e. suppressPopup) {
3976
+ + if (suppressPopup) {
3964
3977
+ hideProgress()
3965
3978
+ } else {
3966
3979
+ if (!visibleProgress) {
@@ -3974,10 +3987,10 @@ index 98573a206f14928fc3fdf18fe927cb75034e4ad1..a031f76924abf8f10c510ea9c043f670
3974
3987
reconnectWaitEvent = e;
3975
3988
- visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reconnectButton, reloadButton]);
3976
3989
- visibleProgress.startTimer(Date.now() + 1000 * e.durationSeconds);
3977
- + if (e. suppressPopup) {
3990
+ + if (suppressPopup) {
3978
3991
+ hideProgress()
3979
3992
+ } else {
3980
- + const location = e. forceDialog ? ProgressLocation.Dialog : (lastLocation || ProgressLocation.Notification)
3993
+ + const location = forceDialog ? ProgressLocation.Dialog : (lastLocation || ProgressLocation.Notification)
3981
3994
+ visibleProgress = showProgress(location, [reconnectButton, reloadButton]);
3982
3995
+ visibleProgress.startTimer(Date.now() + 1000 * e.durationSeconds);
3983
3996
+ }
@@ -3993,7 +4006,7 @@ index 98573a206f14928fc3fdf18fe927cb75034e4ad1..a031f76924abf8f10c510ea9c043f670
3993
4006
- // Need to move from dialog if being shown and user needs to type in a prompt
3994
4007
- if (lastLocation === ProgressLocation.Dialog && visibleProgress !== null) {
3995
4008
- visibleProgress = showProgress(ProgressLocation.Notification, [reloadButton], visibleProgress.lastReport);
3996
- + if (e. suppressPopup) {
4009
+ + if (suppressPopup) {
3997
4010
+ hideProgress()
3998
4011
+ } else {
3999
4012
+ visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reloadButton]);
0 commit comments