Pārlūkot izejas kodu

Merge pull request #2686 from overleaf/jpa-fix-parallel-reconnect

[frontend] ConnectionManager: fix parallel reconnect

GitOrigin-RevId: 38619b30dc38fd2732b77c0a785c8ab2857c81ff
Jakob Ackermann 6 gadi atpakaļ
vecāks
revīzija
4d67acc7f5

+ 5 - 5
services/web/frontend/js/ide/connection/ConnectionManager.js

@@ -258,6 +258,7 @@ The editor will refresh in automatically in 10 seconds.\
             // initial connection
             // initial connection
           } else if (state === 'reconnecting') {
           } else if (state === 'reconnecting') {
             // reconnection after a connection has failed
             // reconnection after a connection has failed
+            this.stopReconnectCountdownTimer()
             this.$scope.connection.reconnecting = true
             this.$scope.connection.reconnecting = true
             // if reconnecting takes more than 1s (it doesn't, usually) show the
             // if reconnecting takes more than 1s (it doesn't, usually) show the
             // 'reconnecting...' warning
             // 'reconnecting...' warning
@@ -278,10 +279,10 @@ The editor will refresh in automatically in 10 seconds.\
             // project has been joined
             // project has been joined
           } else if (state === 'waitingCountdown') {
           } else if (state === 'waitingCountdown') {
             // disconnected and waiting to reconnect via the countdown timer
             // disconnected and waiting to reconnect via the countdown timer
-            this.cancelReconnect()
+            this.stopReconnectCountdownTimer()
           } else if (state === 'waitingGracefully') {
           } else if (state === 'waitingGracefully') {
             // disconnected and waiting to reconnect gracefully
             // disconnected and waiting to reconnect gracefully
-            this.cancelReconnect()
+            this.stopReconnectCountdownTimer()
           } else if (state === 'inactive') {
           } else if (state === 'inactive') {
             // disconnected and not trying to reconnect (inactive)
             // disconnected and not trying to reconnect (inactive)
           } else if (state === 'error') {
           } else if (state === 'error') {
@@ -444,7 +445,7 @@ Something went wrong connecting to your project. Please refresh if this continue
         })
         })
 
 
         setTimeout(() => {
         setTimeout(() => {
-          if (!this.connected) {
+          if (!this.connected && !this.countdownTimeoutId) {
             this.countdownTimeoutId = setTimeout(
             this.countdownTimeoutId = setTimeout(
               () => this.decreaseCountdown(connectionId),
               () => this.decreaseCountdown(connectionId),
               1000
               1000
@@ -453,8 +454,7 @@ Something went wrong connecting to your project. Please refresh if this continue
         }, 200)
         }, 200)
       }
       }
 
 
-      cancelReconnect() {
-        this.disconnect()
+      stopReconnectCountdownTimer() {
         // clear timeout and set to null so we know there is no countdown running
         // clear timeout and set to null so we know there is no countdown running
         if (this.countdownTimeoutId != null) {
         if (this.countdownTimeoutId != null) {
           sl_console.log(
           sl_console.log(