From d3c7ea9d32837d1a9c9a29eaf3ff1196b02b8c78 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Tue, 8 Aug 2023 15:45:13 +0200 Subject: [PATCH] Merge pull request #14215 from overleaf/jpa-slow-down-reconnecting [web] slow down reconnecting to real-time on low-level errors GitOrigin-RevId: cc7aba1f8fbc0fceb5dc66145009ba28c6236648 --- .../web/frontend/js/ide/connection/ConnectionManager.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/web/frontend/js/ide/connection/ConnectionManager.js b/services/web/frontend/js/ide/connection/ConnectionManager.js index 74ac7acf8d..957a534e77 100644 --- a/services/web/frontend/js/ide/connection/ConnectionManager.js +++ b/services/web/frontend/js/ide/connection/ConnectionManager.js @@ -150,7 +150,11 @@ export default ConnectionManager = (function () { window.wsRetryHandshake && connectionAttempt++ < window.wsRetryHandshake ) { - return setTimeout(() => this.ide.socket.socket.connect(), 100) + return setTimeout( + () => this.ide.socket.socket.connect(), + // add jitter to spread reconnects + connectionAttempt * (1 + Math.random()) * 1000 + ) } this.updateConnectionManagerState('error') sl_console.log('socket.io error', err)