Merge pull request #2687 from overleaf/jpa-fix-failing-reconnect-caused-by-backend
[frontend] ConnectionManager: fix failing reconnects (caused by backend) GitOrigin-RevId: f66e45fcb22849c2057b24eabde319ae7781ec51
This commit is contained in:
@@ -270,6 +270,8 @@ The editor will refresh in automatically in 10 seconds.\
|
|||||||
this.$scope.connection.stillReconnecting = true
|
this.$scope.connection.stillReconnecting = true
|
||||||
}
|
}
|
||||||
}, 1000)
|
}, 1000)
|
||||||
|
} else if (state === 'reconnectFailed') {
|
||||||
|
// reconnect attempt failed
|
||||||
} else if (state === 'authenticating') {
|
} else if (state === 'authenticating') {
|
||||||
// socket connection has been established, trying to authenticate
|
// socket connection has been established, trying to authenticate
|
||||||
} else if (state === 'joining') {
|
} else if (state === 'joining') {
|
||||||
@@ -507,6 +509,24 @@ Something went wrong connecting to your project. Please refresh if this continue
|
|||||||
}
|
}
|
||||||
this.updateConnectionManagerState('reconnecting')
|
this.updateConnectionManagerState('reconnecting')
|
||||||
sl_console.log('[ConnectionManager] Starting new connection')
|
sl_console.log('[ConnectionManager] Starting new connection')
|
||||||
|
|
||||||
|
const removeHandler = () => {
|
||||||
|
this.ide.socket.removeListener('error', handleFailure)
|
||||||
|
this.ide.socket.removeListener('connect', handleSuccess)
|
||||||
|
}
|
||||||
|
const handleFailure = () => {
|
||||||
|
sl_console.log('[ConnectionManager] tryReconnect: failed')
|
||||||
|
removeHandler()
|
||||||
|
this.updateConnectionManagerState('reconnectFailed')
|
||||||
|
this.tryReconnectWithRateLimit({ force: true })
|
||||||
|
}
|
||||||
|
const handleSuccess = () => {
|
||||||
|
sl_console.log('[ConnectionManager] tryReconnect: success')
|
||||||
|
removeHandler()
|
||||||
|
}
|
||||||
|
this.ide.socket.on('error', handleFailure)
|
||||||
|
this.ide.socket.on('connect', handleSuccess)
|
||||||
|
|
||||||
// use socket.io connect() here to make a single attempt, the
|
// use socket.io connect() here to make a single attempt, the
|
||||||
// reconnect() method makes multiple attempts
|
// reconnect() method makes multiple attempts
|
||||||
this.ide.socket.socket.connect()
|
this.ide.socket.socket.connect()
|
||||||
|
|||||||
Reference in New Issue
Block a user