From 873afd8325ff8699154efd41326f7ef9e7067a0d Mon Sep 17 00:00:00 2001 From: Mark Nadal Date: Sun, 2 Oct 2016 09:58:13 -0700 Subject: [PATCH] fix @d3x0r 's double close --- gun.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gun.js b/gun.js index d49f518d..9b37d793 100644 --- a/gun.js +++ b/gun.js @@ -2104,8 +2104,8 @@ (ws = r.ws.peers[opt.base] = new WS(opt.base.replace('http','ws'))).cbs = {}; ws.onopen = function(o){ r.back = 2; r.ws(opt, cb) }; ws.onclose = window.onbeforeunload = function(c){ - if(!c){ return } - if(ws && ws.close instanceof Function){ ws.close() } + if(!ws || !c){ return } + if(ws.close instanceof Function){ ws.close() } if(!ws.sending){ ws = r.ws.peers[opt.base] = false; return r.transport(opt, cb);