Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 70133f6

Browse files
authored
Merge pull request #2284 from nielsen-oss/nielsen
Implement background reconnection
2 parents 2a3608d + 12ab91b commit 70133f6

File tree

1 file changed

+155
-1
lines changed

1 file changed

+155
-1
lines changed

‎ci/dev/vscode.patch‎

Lines changed: 155 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ index 3715cbb8e6ee41c3d9b5090918d243b723ae2d00..c65de8ad37e727d66da97a8f8b170cbc
689689
-
690690
-
691691
diff --git a/src/vs/platform/remote/common/remoteAgentConnection.ts b/src/vs/platform/remote/common/remoteAgentConnection.ts
692-
index 18d3d04fd20335975293e37b3b641120dd92da20..4e49f9d63623da6c84624144765f76ec127ea526 100644
692+
index 18d3d04fd20335975293e37b3b641120dd92da20..a06f20ece490dba5d88b41268cddaaf6b2f6b64a 100644
693693
--- a/src/vs/platform/remote/common/remoteAgentConnection.ts
694694
+++ b/src/vs/platform/remote/common/remoteAgentConnection.ts
695695
@@ -92,7 +92,7 @@ async function connectToRemoteExtensionHostAgent(options: ISimpleConnectionOptio
@@ -701,6 +701,82 @@ index 18d3d04fd20335975293e37b3b641120dd92da20..4e49f9d63623da6c84624144765f76ec
701701
(err: any, socket: ISocket | undefined) => {
702702
if (err || !socket) {
703703
options.logService.error(`${logPrefix} socketFactory.connect() failed. Error:`);
704+
@@ -331,12 +331,16 @@ export const enum PersistentConnectionEventType {
705+
}
706+
export class ConnectionLostEvent {
707+
public readonly type = PersistentConnectionEventType.ConnectionLost;
708+
+ constructor(
709+
+ public readonly connectionAttempt?: number
710+
+ ) { }
711+
}
712+
export class ReconnectionWaitEvent {
713+
public readonly type = PersistentConnectionEventType.ReconnectionWait;
714+
constructor(
715+
public readonly durationSeconds: number,
716+
- private readonly cancellableTimer: CancelablePromise<void>
717+
+ private readonly cancellableTimer: CancelablePromise<void>,
718+
+ public readonly connectionAttempt?: number,
719+
) { }
720+
721+
public skipWait(): void {
722+
@@ -345,12 +349,21 @@ export class ReconnectionWaitEvent {
723+
}
724+
export class ReconnectionRunningEvent {
725+
public readonly type = PersistentConnectionEventType.ReconnectionRunning;
726+
+ constructor(
727+
+ public readonly connectionAttempt?: number
728+
+ ) { }
729+
}
730+
export class ConnectionGainEvent {
731+
public readonly type = PersistentConnectionEventType.ConnectionGain;
732+
+ constructor(
733+
+ public readonly connectionAttempt?: number
734+
+ ) { }
735+
}
736+
export class ReconnectionPermanentFailureEvent {
737+
public readonly type = PersistentConnectionEventType.ReconnectionPermanentFailure;
738+
+ constructor(
739+
+ public readonly connectionAttempt?: number
740+
+ ) { }
741+
}
742+
export type PersistenConnectionEvent = ConnectionGainEvent | ConnectionLostEvent | ReconnectionWaitEvent | ReconnectionRunningEvent | ReconnectionPermanentFailureEvent;
743+
744+
@@ -411,8 +424,9 @@ abstract class PersistentConnection extends Disposable {
745+
}
746+
const logPrefix = commonLogPrefix(this._connectionType, this.reconnectionToken, true);
747+
this._options.logService.info(`${logPrefix} starting reconnecting loop. You can get more information with the trace log level.`);
748+
- this._onDidStateChange.fire(new ConnectionLostEvent());
749+
+ this._onDidStateChange.fire(new ConnectionLostEvent(0));
750+
const TIMES = [5, 5, 10, 10, 10, 10, 10, 30];
751+
+
752+
const disconnectStartTime = Date.now();
753+
let attempt = -1;
754+
do {
755+
@@ -420,7 +434,7 @@ abstract class PersistentConnection extends Disposable {
756+
const waitTime = (attempt < TIMES.length ? TIMES[attempt] : TIMES[TIMES.length - 1]);
757+
try {
758+
const sleepPromise = sleep(waitTime);
759+
- this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise));
760+
+ this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise, attempt));
761+
762+
this._options.logService.info(`${logPrefix} waiting for ${waitTime} seconds before reconnecting...`);
763+
try {
764+
@@ -433,13 +447,13 @@ abstract class PersistentConnection extends Disposable {
765+
}
766+
767+
// connection was lost, let's try to re-establish it
768+
- this._onDidStateChange.fire(new ReconnectionRunningEvent());
769+
+ this._onDidStateChange.fire(new ReconnectionRunningEvent(attempt));
770+
this._options.logService.info(`${logPrefix} resolving connection...`);
771+
const simpleOptions = await resolveConnectionOptions(this._options, this.reconnectionToken, this.protocol);
772+
this._options.logService.info(`${logPrefix} connecting to ${simpleOptions.host}:${simpleOptions.port}...`);
773+
await connectWithTimeLimit(simpleOptions.logService, this._reconnect(simpleOptions), RECONNECT_TIMEOUT);
774+
this._options.logService.info(`${logPrefix} reconnected!`);
775+
- this._onDidStateChange.fire(new ConnectionGainEvent());
776+
+ this._onDidStateChange.fire(new ConnectionGainEvent(attempt));
777+
778+
break;
779+
} catch (err) {
704780
diff --git a/src/vs/platform/storage/browser/storageService.ts b/src/vs/platform/storage/browser/storageService.ts
705781
index ab3fd347b69f8a3d9b96e706cd87c911b8ffed6b..9d351037b577f9f1edfd18ae9b3c48a211f4467f 100644
706782
--- a/src/vs/platform/storage/browser/storageService.ts
@@ -3199,6 +3275,84 @@ index 94e7e7a4bac154c45078a1b5034e50634a7a43af..8164200dcef1efbc65b50eef9c270af3
31993275
this._filenameKey.set(value ? basename(value) : null);
32003276
this._dirnameKey.set(value ? dirname(value).fsPath : null);
32013277
this._pathKey.set(value ? value.fsPath : null);
3278+
diff --git a/src/vs/workbench/contrib/remote/browser/remote.ts b/src/vs/workbench/contrib/remote/browser/remote.ts
3279+
index 98573a206f14928fc3fdf18fe927cb75034e4ad1..1430666aa94f941bda086df503fec8b35aa2b25f 100644
3280+
--- a/src/vs/workbench/contrib/remote/browser/remote.ts
3281+
+++ b/src/vs/workbench/contrib/remote/browser/remote.ts
3282+
@@ -730,6 +730,7 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution {
3283+
@IContextKeyService contextKeyService: IContextKeyService
3284+
) {
3285+
const connection = remoteAgentService.getConnection();
3286+
+ const SHOW_POPUP_ON_ATTEMPT = 2 // aka third attempt
3287+
if (connection) {
3288+
let visibleProgress: VisibleProgress | null = null;
3289+
let lastLocation: ProgressLocation.Dialog | ProgressLocation.Notification | null = null;
3290+
@@ -793,33 +794,47 @@ class RemoteAgentConnectionStatusListener implements IWorkbenchContribution {
3291+
disposableListener.dispose();
3292+
disposableListener = null;
3293+
}
3294+
+ let suppressPopup = (typeof e.connectionAttempt == 'number' && e.connectionAttempt < SHOW_POPUP_ON_ATTEMPT)
3295+
+ let forceDialog = (typeof e.connectionAttempt == 'number' && e.connectionAttempt == SHOW_POPUP_ON_ATTEMPT)
3296+
switch (e.type) {
3297+
case PersistentConnectionEventType.ConnectionLost:
3298+
- if (!visibleProgress) {
3299+
- visibleProgress = showProgress(ProgressLocation.Dialog, [reconnectButton, reloadButton]);
3300+
+ if (suppressPopup) {
3301+
+ hideProgress()
3302+
+ } else {
3303+
+ if (!visibleProgress) {
3304+
+ visibleProgress = showProgress(ProgressLocation.Dialog, [reconnectButton, reloadButton]);
3305+
+ }
3306+
+ visibleProgress.report(nls.localize('connectionLost', "Connection Lost"));
3307+
}
3308+
- visibleProgress.report(nls.localize('connectionLost', "Connection Lost"));
3309+
break;
3310+
case PersistentConnectionEventType.ReconnectionWait:
3311+
reconnectWaitEvent = e;
3312+
- visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reconnectButton, reloadButton]);
3313+
- visibleProgress.startTimer(Date.now() + 1000 * e.durationSeconds);
3314+
+ if (suppressPopup) {
3315+
+ hideProgress()
3316+
+ } else {
3317+
+ const location = forceDialog ? ProgressLocation.Dialog : (lastLocation || ProgressLocation.Notification)
3318+
+ visibleProgress = showProgress(location, [reconnectButton, reloadButton]);
3319+
+ visibleProgress.startTimer(Date.now() + 1000 * e.durationSeconds);
3320+
+ }
3321+
break;
3322+
case PersistentConnectionEventType.ReconnectionRunning:
3323+
- visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reloadButton]);
3324+
- visibleProgress.report(nls.localize('reconnectionRunning', "Attempting to reconnect..."));
3325+
-
3326+
- // Register to listen for quick input is opened
3327+
- disposableListener = contextKeyService.onDidChangeContext((contextKeyChangeEvent) => {
3328+
- const reconnectInteraction = new Set<string>([inQuickPickContextKeyValue]);
3329+
- if (contextKeyChangeEvent.affectsSome(reconnectInteraction)) {
3330+
- // Need to move from dialog if being shown and user needs to type in a prompt
3331+
- if (lastLocation === ProgressLocation.Dialog && visibleProgress !== null) {
3332+
- visibleProgress = showProgress(ProgressLocation.Notification, [reloadButton], visibleProgress.lastReport);
3333+
+ if (suppressPopup) {
3334+
+ hideProgress()
3335+
+ } else {
3336+
+ visibleProgress = showProgress(lastLocation || ProgressLocation.Notification, [reloadButton]);
3337+
+ visibleProgress.report(nls.localize('reconnectionRunning', "Attempting to reconnect..."));
3338+
+
3339+
+ // Register to listen for quick input is opened
3340+
+ disposableListener = contextKeyService.onDidChangeContext((contextKeyChangeEvent) => {
3341+
+ const reconnectInteraction = new Set<string>([inQuickPickContextKeyValue]);
3342+
+ if (contextKeyChangeEvent.affectsSome(reconnectInteraction)) {
3343+
+ // Need to move from dialog if being shown and user needs to type in a prompt
3344+
+ if (lastLocation === ProgressLocation.Dialog && visibleProgress !== null) {
3345+
+ visibleProgress = showProgress(ProgressLocation.Notification, [reloadButton], visibleProgress.lastReport);
3346+
+ }
3347+
}
3348+
- }
3349+
- });
3350+
-
3351+
+ });
3352+
+ }
3353+
break;
3354+
case PersistentConnectionEventType.ReconnectionPermanentFailure:
3355+
hideProgress();
32023356
diff --git a/src/vs/workbench/contrib/scm/browser/media/scm.css b/src/vs/workbench/contrib/scm/browser/media/scm.css
32033357
index ac44ad3bae428def66e22fe9cc1c54648d429f6b..faa63023c4c586b51fa3c2a48ff3641b9cb0e145 100644
32043358
--- a/src/vs/workbench/contrib/scm/browser/media/scm.css

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /