Skip to content

Commit 51eb625

Browse files
committed
vscode: Reconnect in the background
Based on the previous commits by @mgmachado but simplified.
1 parent cf4d752 commit 51eb625

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

ci/dev/vscode.patch

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ index 3715cbb8e6ee41c3d9b5090918d243b723ae2d00..c65de8ad37e727d66da97a8f8b170cbc
712712
-
713713
-
714714
diff --git a/src/vs/platform/remote/common/remoteAgentConnection.ts b/src/vs/platform/remote/common/remoteAgentConnection.ts
715-
index 18d3d04fd20335975293e37b3b641120dd92da20..a06f20ece490dba5d88b41268cddaaf6b2f6b64a 100644
715+
index fdd5890c69f72025b94913380f0d226226e8c8fb..957b4812783f6b1d97d1003c63725f541042059f 100644
716716
--- a/src/vs/platform/remote/common/remoteAgentConnection.ts
717717
+++ b/src/vs/platform/remote/common/remoteAgentConnection.ts
718718
@@ -93,7 +93,7 @@ async function connectToRemoteExtensionHostAgent(options: ISimpleConnectionOptio
@@ -724,6 +724,25 @@ index 18d3d04fd20335975293e37b3b641120dd92da20..a06f20ece490dba5d88b41268cddaaf6
724724
(err: any, socket: ISocket | undefined) => {
725725
if (err || !socket) {
726726
options.logService.error(`${logPrefix} socketFactory.connect() failed. Error:`);
727+
@@ -338,7 +338,8 @@ export class ReconnectionWaitEvent {
728+
public readonly type = PersistentConnectionEventType.ReconnectionWait;
729+
constructor(
730+
public readonly durationSeconds: number,
731+
- private readonly cancellableTimer: CancelablePromise<void>
732+
+ private readonly cancellableTimer: CancelablePromise<void>,
733+
+ public readonly connectionAttempt: number
734+
) { }
735+
736+
public skipWait(): void {
737+
@@ -422,7 +423,7 @@ abstract class PersistentConnection extends Disposable {
738+
const waitTime = (attempt < TIMES.length ? TIMES[attempt] : TIMES[TIMES.length - 1]);
739+
try {
740+
const sleepPromise = sleep(waitTime);
741+
- this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise));
742+
+ this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise, attempt+1));
743+
744+
this._options.logService.info(`${logPrefix} waiting for ${waitTime} seconds before reconnecting...`);
745+
try {
727746
diff --git a/src/vs/platform/storage/browser/storageService.ts b/src/vs/platform/storage/browser/storageService.ts
728747
index ab3fd347b69f8a3d9b96e706cd87c911b8ffed6b..9d351037b577f9f1edfd18ae9b3c48a211f4467f 100644
729748
--- a/src/vs/platform/storage/browser/storageService.ts
@@ -3853,6 +3872,43 @@ index 94e7e7a4bac154c45078a1b5034e50634a7a43af..8164200dcef1efbc65b50eef9c270af3
38533872
this._filenameKey.set(value ? basename(value) : null);
38543873
this._dirnameKey.set(value ? dirname(value).fsPath : null);
38553874
this._pathKey.set(value ? value.fsPath : null);
3875+
diff --git a/src/vs/workbench/contrib/remote/browser/remote.ts b/src/vs/workbench/contrib/remote/browser/remote.ts
3876+
index c6d98b601a3b6966e8a99d2c05b3b7f02b08e6ca..c2a76fbd75d24d509f312cb8bf094eb297374f04 100644
3877+
--- a/src/vs/workbench/contrib/remote/browser/remote.ts
3878+
+++ b/src/vs/workbench/contrib/remote/browser/remote.ts
3879+
@@ -778,17 +778,30 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution {
3880+
}
3881+
switch (e.type) {
3882+
case PersistentConnectionEventType.ConnectionLost:
3883+
+ break;
3884+
+ case PersistentConnectionEventType.ReconnectionWait:
3885+
+ const BACKGROUND_RECONNECT_THRESHOLD = 2;
3886+
+ // If the first reconnect fails, we show the popup.
3887+
+ // This corresponds to about 5s wait.
3888+
+ if (e.connectionAttempt < BACKGROUND_RECONNECT_THRESHOLD) {
3889+
+ break;
3890+
+ }
3891+
+
3892+
if (!visibleProgress) {
3893+
visibleProgress = showProgress(ProgressLocation.Dialog, [reconnectButton, reloadButton]);
3894+
}
3895+
visibleProgress.report(nls.localize('connectionLost', "Connection Lost"));
3896+
- break;
3897+
- case PersistentConnectionEventType.ReconnectionWait:
3898+
+
3899+
reconnectWaitEvent = e;
3900+
visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reconnectButton, reloadButton]);
3901+
visibleProgress.startTimer(Date.now() + 1000 * e.durationSeconds);
3902+
break;
3903+
case PersistentConnectionEventType.ReconnectionRunning:
3904+
+ if (!visibleProgress) {
3905+
+ // Our background reconnection threshold hasn't been hit yet.
3906+
+ break;
3907+
+ }
3908+
+
3909+
visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reloadButton]);
3910+
visibleProgress.report(nls.localize('reconnectionRunning', "Attempting to reconnect..."));
3911+
38563912
diff --git a/src/vs/workbench/contrib/scm/browser/media/scm.css b/src/vs/workbench/contrib/scm/browser/media/scm.css
38573913
index 74f6922e98b4bb6a7fb100f5aac015afe9fc171b..3243a97c2d378013d96ffbe87e9df6dd4a66776d 100644
38583914
--- a/src/vs/workbench/contrib/scm/browser/media/scm.css

0 commit comments

Comments
 (0)