Skip to content

Commit 02a8e6c

Browse files
committed
Set backoff when trying to connect to the socket
1 parent f870895 commit 02a8e6c

File tree

1 file changed

+14
-0
lines changed
  • packages/app/src/app/overmind/effects/live

1 file changed

+14
-0
lines changed

packages/app/src/app/overmind/effects/live/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,20 @@ export default new (class Live {
8484
},
8585
});
8686

87+
_socket.onClose(e => {
88+
if (e.code === 1006) {
89+
// This is an abrupt close, the server probably restarted or carshed. We don't want to overload
90+
// the server, so we manually wait and try to connect;
91+
_socket.disconnect();
92+
93+
const waitTime = 5000 * Math.random();
94+
95+
setTimeout(() => {
96+
_socket.connect();
97+
}, waitTime);
98+
}
99+
});
100+
87101
_socket.connect();
88102
window.socket = _socket;
89103
debug('Connecting to socket', _socket);

0 commit comments

Comments
 (0)