Do not wait for the first reconnection attempt in the reconnection loop

上级 b64a4ae1
...@@ -454,20 +454,22 @@ abstract class PersistentConnection extends Disposable { ...@@ -454,20 +454,22 @@ abstract class PersistentConnection extends Disposable {
const logPrefix = commonLogPrefix(this._connectionType, this.reconnectionToken, true); 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._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())); 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(); const disconnectStartTime = Date.now();
let attempt = -1; let attempt = -1;
do { do {
attempt++; attempt++;
const waitTime = (attempt < TIMES.length ? TIMES[attempt] : TIMES[TIMES.length - 1]); const waitTime = (attempt < TIMES.length ? TIMES[attempt] : TIMES[TIMES.length - 1]);
try { try {
const sleepPromise = sleep(waitTime); if (waitTime > 0) {
this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, this.protocol.getMillisSinceLastIncomingData(), sleepPromise)); 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 { this._options.logService.info(`${logPrefix} waiting for ${waitTime} seconds before reconnecting...`);
await sleepPromise; try {
} catch { } // User canceled timer await sleepPromise;
} catch { } // User canceled timer
}
if (PersistentConnection._permanentFailure) { if (PersistentConnection._permanentFailure) {
this._options.logService.error(`${logPrefix} permanent failure occurred while running the reconnecting loop.`); this._options.logService.error(`${logPrefix} permanent failure occurred while running the reconnecting loop.`);
......
...@@ -791,7 +791,7 @@ class RemoteAgentConnectionStatusListener extends Disposable implements IWorkben ...@@ -791,7 +791,7 @@ class RemoteAgentConnectionStatusListener extends Disposable implements IWorkben
// Possible state transitions: // Possible state transitions:
// ConnectionGain -> ConnectionLost // ConnectionGain -> ConnectionLost
// ConnectionLost -> ReconnectionWait // ConnectionLost -> ReconnectionWait, ReconnectionRunning
// ReconnectionWait -> ReconnectionRunning // ReconnectionWait -> ReconnectionRunning
// ReconnectionRunning -> ConnectionGain, ReconnectionPermanentFailure // ReconnectionRunning -> ConnectionGain, ReconnectionPermanentFailure
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册