Skip to content

Commit faefac5

Browse files
authored
Merge pull request #1 from nielsen-oss/feature/suppress_reconnect_popups_at_first
show reconnection popup on third attempt
2 parents 1eebde5 + b2abfa7 commit faefac5

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

ci/dev/vscode.patch

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ index 3715cbb8e6ee41c3d9b5090918d243b723ae2d00..c65de8ad37e727d66da97a8f8b170cbc
677677
-
678678
-
679679
diff --git a/src/vs/platform/remote/common/remoteAgentConnection.ts b/src/vs/platform/remote/common/remoteAgentConnection.ts
680-
index 18d3d04fd20335975293e37b3b641120dd92da20..4e49f9d63623da6c84624144765f76ec127ea526 100644
680+
index 18d3d04fd20335975293e37b3b641120dd92da20..e072fc38ccd950462f42fdf112c8e7e673f351f5 100644
681681
--- a/src/vs/platform/remote/common/remoteAgentConnection.ts
682682
+++ b/src/vs/platform/remote/common/remoteAgentConnection.ts
683683
@@ -92,7 +92,7 @@ async function connectToRemoteExtensionHostAgent(options: ISimpleConnectionOptio
@@ -689,6 +689,53 @@ index 18d3d04fd20335975293e37b3b641120dd92da20..4e49f9d63623da6c84624144765f76ec
689689
(err: any, socket: ISocket | undefined) => {
690690
if (err || !socket) {
691691
options.logService.error(`${logPrefix} socketFactory.connect() failed. Error:`);
692+
@@ -411,16 +411,23 @@ abstract class PersistentConnection extends Disposable {
693+
}
694+
const logPrefix = commonLogPrefix(this._connectionType, this.reconnectionToken, true);
695+
this._options.logService.info(`${logPrefix} starting reconnecting loop. You can get more information with the trace log level.`);
696+
- this._onDidStateChange.fire(new ConnectionLostEvent());
697+
const TIMES = [5, 5, 10, 10, 10, 10, 10, 30];
698+
+ const SHOW_POPUP_ON_ATTEMPT = 2 // aka third attempt
699+
+
700+
const disconnectStartTime = Date.now();
701+
let attempt = -1;
702+
do {
703+
attempt++;
704+
+ if (attempt == SHOW_POPUP_ON_ATTEMPT){
705+
+ this._onDidStateChange.fire(new ConnectionLostEvent());
706+
+ }
707+
+
708+
const waitTime = (attempt < TIMES.length ? TIMES[attempt] : TIMES[TIMES.length - 1]);
709+
try {
710+
const sleepPromise = sleep(waitTime);
711+
- this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise));
712+
+ if (attempt >= SHOW_POPUP_ON_ATTEMPT) {
713+
+ this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise));
714+
+ }
715+
716+
this._options.logService.info(`${logPrefix} waiting for ${waitTime} seconds before reconnecting...`);
717+
try {
718+
@@ -433,14 +440,17 @@ abstract class PersistentConnection extends Disposable {
719+
}
720+
721+
// connection was lost, let's try to re-establish it
722+
- this._onDidStateChange.fire(new ReconnectionRunningEvent());
723+
+ if (attempt >= SHOW_POPUP_ON_ATTEMPT){
724+
+ this._onDidStateChange.fire(new ReconnectionRunningEvent());
725+
+ }
726+
this._options.logService.info(`${logPrefix} resolving connection...`);
727+
const simpleOptions = await resolveConnectionOptions(this._options, this.reconnectionToken, this.protocol);
728+
this._options.logService.info(`${logPrefix} connecting to ${simpleOptions.host}:${simpleOptions.port}...`);
729+
await connectWithTimeLimit(simpleOptions.logService, this._reconnect(simpleOptions), RECONNECT_TIMEOUT);
730+
this._options.logService.info(`${logPrefix} reconnected!`);
731+
- this._onDidStateChange.fire(new ConnectionGainEvent());
732+
-
733+
+ if (attempt >= SHOW_POPUP_ON_ATTEMPT) {
734+
+ this._onDidStateChange.fire(new ConnectionGainEvent());
735+
+ }
736+
break;
737+
} catch (err) {
738+
if (err.code === 'VSCODE_CONNECTION_ERROR') {
692739
diff --git a/src/vs/platform/storage/browser/storageService.ts b/src/vs/platform/storage/browser/storageService.ts
693740
index ab3fd347b69f8a3d9b96e706cd87c911b8ffed6b..9d351037b577f9f1edfd18ae9b3c48a211f4467f 100644
694741
--- a/src/vs/platform/storage/browser/storageService.ts

0 commit comments

Comments
 (0)