Skip to content

Commit 71edbbc

Browse files
authored
Implemented fix to match HubConnection.cs logic (#42806) (#62812)
1 parent 0e7095b commit 71edbbc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/SignalR/clients/ts/signalr/src/HubConnection.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ export class HubConnection {
871871
let previousReconnectAttempts = 0;
872872
let retryError = error !== undefined ? error : new Error("Attempting to reconnect due to a unknown error.");
873873

874-
let nextRetryDelay = this._getNextRetryDelay(previousReconnectAttempts++, 0, retryError);
874+
let nextRetryDelay = this._getNextRetryDelay(previousReconnectAttempts, 0, retryError);
875875

876876
if (nextRetryDelay === null) {
877877
this._logger.log(LogLevel.Debug, "Connection not reconnecting because the IRetryPolicy returned null on the first reconnect attempt.");
@@ -902,7 +902,7 @@ export class HubConnection {
902902
}
903903

904904
while (nextRetryDelay !== null) {
905-
this._logger.log(LogLevel.Information, `Reconnect attempt number ${previousReconnectAttempts} will start in ${nextRetryDelay} ms.`);
905+
this._logger.log(LogLevel.Information, `Reconnect attempt number ${previousReconnectAttempts + 1} will start in ${nextRetryDelay} ms.`);
906906

907907
await new Promise((resolve) => {
908908
this._reconnectDelayHandle = setTimeout(resolve, nextRetryDelay!);
@@ -941,8 +941,9 @@ export class HubConnection {
941941
return;
942942
}
943943

944+
previousReconnectAttempts++;
944945
retryError = e instanceof Error ? e : new Error((e as any).toString());
945-
nextRetryDelay = this._getNextRetryDelay(previousReconnectAttempts++, Date.now() - reconnectStartTime, retryError);
946+
nextRetryDelay = this._getNextRetryDelay(previousReconnectAttempts, Date.now() - reconnectStartTime, retryError);
946947
}
947948
}
948949

0 commit comments

Comments
 (0)