From ba673f73f8f4bf9177beef01d1138cb02b047add Mon Sep 17 00:00:00 2001 From: Jesse Gibson Date: Tue, 13 Dec 2016 13:37:43 -0700 Subject: [PATCH] Attempt reconnect on disconnect Previously, the client websocket layer would only attempt a reconnection if there were pending messages in the queue. Now it will always attempt a reconnection, solving most of issue #259 (although not completely, as reconnects are susceptible to race conditions). --- gun.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/gun.js b/gun.js index b8b6c08e..b47a1e6f 100644 --- a/gun.js +++ b/gun.js @@ -1,5 +1,5 @@ //console.log("!!!!!!!!!!!!!!!! WARNING THIS IS GUN 0.5 !!!!!!!!!!!!!!!!!!!!!!"); -;(function(){ +;(function(){ /* UNBUILD */ var root; @@ -2236,13 +2236,9 @@ client.on('message', msg); }); + // Reconnect on close events. socket.addEventListener('close', function () { - - // Attempt reconnect if requests are pending. - if (client.queue.length) { - client.scheduleReconnect(); - } - + client.scheduleReconnect(); }); // Send the messages in the queue.