diff --git a/src/vs/platform/remote/common/remoteAgentConnection.ts b/src/vs/platform/remote/common/remoteAgentConnection.ts index 20d5854b4b1bf45648335c80e5a950fe280de7c3..2232dddc71bb57ebc7e1f2b4565fbdd8d6a6b94f 100644 --- a/src/vs/platform/remote/common/remoteAgentConnection.ts +++ b/src/vs/platform/remote/common/remoteAgentConnection.ts @@ -454,20 +454,22 @@ abstract class PersistentConnection extends Disposable { const logPrefix = commonLogPrefix(this._connectionType, this.reconnectionToken, true); this._options.logService.info(`${logPrefix} starting reconnecting loop. You can get more information with the trace log level.`); this._onDidStateChange.fire(new ConnectionLostEvent(this.protocol.getMillisSinceLastIncomingData())); - const TIMES = [5, 5, 10, 10, 10, 10, 10, 30]; + const TIMES = [0, 5, 5, 10, 10, 10, 10, 10, 30]; const disconnectStartTime = Date.now(); let attempt = -1; do { attempt++; const waitTime = (attempt < TIMES.length ? TIMES[attempt] : TIMES[TIMES.length - 1]); try { - const sleepPromise = sleep(waitTime); - this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, this.protocol.getMillisSinceLastIncomingData(), sleepPromise)); - - this._options.logService.info(`${logPrefix} waiting for ${waitTime} seconds before reconnecting...`); - try { - await sleepPromise; - } catch { } // User canceled timer + if (waitTime > 0) { + const sleepPromise = sleep(waitTime); + this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, this.protocol.getMillisSinceLastIncomingData(), sleepPromise)); + + this._options.logService.info(`${logPrefix} waiting for ${waitTime} seconds before reconnecting...`); + try { + await sleepPromise; + } catch { } // User canceled timer + } if (PersistentConnection._permanentFailure) { this._options.logService.error(`${logPrefix} permanent failure occurred while running the reconnecting loop.`); diff --git a/src/vs/workbench/contrib/remote/browser/remote.ts b/src/vs/workbench/contrib/remote/browser/remote.ts index 2b02cb6b30f38dc6326c04a2c63603fbc0584e43..d70aae6ded39c4a9dda7b0b5618f4df82d2d869a 100644 --- a/src/vs/workbench/contrib/remote/browser/remote.ts +++ b/src/vs/workbench/contrib/remote/browser/remote.ts @@ -791,7 +791,7 @@ class RemoteAgentConnectionStatusListener extends Disposable implements IWorkben // Possible state transitions: // ConnectionGain -> ConnectionLost - // ConnectionLost -> ReconnectionWait + // ConnectionLost -> ReconnectionWait, ReconnectionRunning // ReconnectionWait -> ReconnectionRunning // ReconnectionRunning -> ConnectionGain, ReconnectionPermanentFailure