mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Only retry connecting to the reload server for a second
The port changes when the reload server is restarted in any case, so no point trying to reconnect if the server has gone away.
This commit is contained in:
parent
6e874b5377
commit
467f7a3273
@ -8,6 +8,7 @@
|
||||
(function(autoreload_port) {
|
||||
"use strict;";
|
||||
var url = 'ws://127.0.0.1:' + autoreload_port;
|
||||
var MAX_RETRIES = 10;
|
||||
|
||||
function ReconnectingWebSocket() {
|
||||
self = this;
|
||||
@ -31,10 +32,9 @@
|
||||
self.ws.onclose = function(event) {
|
||||
console.log('Connection to reload server closed with code: ' + event.code + ' and reason: ' + event.reason);
|
||||
self.retries += 1;
|
||||
if (self.retries < 60) {
|
||||
self.interval *= 2;
|
||||
if (self.retries < MAX_RETRIES) {
|
||||
setTimeout(self.reconnect, self.interval);
|
||||
}
|
||||
} else window.location.reload(true);
|
||||
};
|
||||
};
|
||||
self.reconnect();
|
||||
|
Loading…
x
Reference in New Issue
Block a user