@@ -746,6 +746,53 @@ index fdd5890c69f72025b94913380f0d226226e8c8fb..e084236526b38c1144d47b8b3000b367
746746 (err: any, socket: ISocket | undefined) => {
747747 if (err || !socket) {
748748 options.logService.error(`${logPrefix} socketFactory.connect() failed. Error:`);
749+ @@ -411,16 +411,23 @@ abstract class PersistentConnection extends Disposable {
750+ }
751+ const logPrefix = commonLogPrefix(this._connectionType, this.reconnectionToken, true);
752+ this._options.logService.info(`${logPrefix} starting reconnecting loop. You can get more information with the trace log level.`);
753+ - this._onDidStateChange.fire(new ConnectionLostEvent());
754+ const TIMES = [5, 5, 10, 10, 10, 10, 10, 30];
755+ + const SHOW_POPUP_ON_ATTEMPT = 2 // aka third attempt
756+ +
757+ const disconnectStartTime = Date.now();
758+ let attempt = -1;
759+ do {
760+ attempt++;
761+ + if (attempt == SHOW_POPUP_ON_ATTEMPT){
762+ + this._onDidStateChange.fire(new ConnectionLostEvent());
763+ + }
764+ +
765+ const waitTime = (attempt < TIMES.length ? TIMES[attempt] : TIMES[TIMES.length - 1]);
766+ try {
767+ const sleepPromise = sleep(waitTime);
768+ - this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise));
769+ + if (attempt >= SHOW_POPUP_ON_ATTEMPT) {
770+ + this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise));
771+ + }
772+
773+ this._options.logService.info(`${logPrefix} waiting for ${waitTime} seconds before reconnecting...`);
774+ try {
775+ @@ -433,14 +440,17 @@ abstract class PersistentConnection extends Disposable {
776+ }
777+
778+ // connection was lost, let's try to re-establish it
779+ - this._onDidStateChange.fire(new ReconnectionRunningEvent());
780+ + if (attempt >= SHOW_POPUP_ON_ATTEMPT){
781+ + this._onDidStateChange.fire(new ReconnectionRunningEvent());
782+ + }
783+ this._options.logService.info(`${logPrefix} resolving connection...`);
784+ const simpleOptions = await resolveConnectionOptions(this._options, this.reconnectionToken, this.protocol);
785+ this._options.logService.info(`${logPrefix} connecting to ${simpleOptions.host}:${simpleOptions.port}...`);
786+ await connectWithTimeLimit(simpleOptions.logService, this._reconnect(simpleOptions), RECONNECT_TIMEOUT);
787+ this._options.logService.info(`${logPrefix} reconnected!`);
788+ - this._onDidStateChange.fire(new ConnectionGainEvent());
789+ -
790+ + if (attempt >= SHOW_POPUP_ON_ATTEMPT) {
791+ + this._onDidStateChange.fire(new ConnectionGainEvent());
792+ + }
793+ break;
794+ } catch (err) {
795+ if (err.code === 'VSCODE_CONNECTION_ERROR') {
749796diff --git a/src/vs/platform/storage/browser/storageService.ts b/src/vs/platform/storage/browser/storageService.ts
750797index ab3fd347b69f8a3d9b96e706cd87c911b8ffed6b..9d351037b577f9f1edfd18ae9b3c48a211f4467f 100644
751798--- a/src/vs/platform/storage/browser/storageService.ts
0 commit comments