From 83ee2fd2f3b34d351620d2b2c28b3e7f556254c4 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Sat, 17 Feb 2018 13:47:04 +0100 Subject: [PATCH] ipc: prevent some more errors --- app/main/ipc/client.js | 2 ++ src/browser/js/app/ipc/index.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/app/main/ipc/client.js b/app/main/ipc/client.js index b815253e..aa08546d 100644 --- a/app/main/ipc/client.js +++ b/app/main/ipc/client.js @@ -45,6 +45,7 @@ class Socket extends EventEmitter { this.dieTimeout = clearTimeout(this.dieTimeout) this.hearbeat = setInterval(()=>{ + if (!this.connected()) return this.socket.send(`["ping"]`) this.hearbeatTimeout = setTimeout(()=>{ if (this.connected()) this.socket.close() @@ -57,6 +58,7 @@ class Socket extends EventEmitter { this.hearbeat = clearInterval(this.hearbeat) this.hearbeatTimeout = clearTimeout(this.hearbeatTimeout) + this.dieTimeout = clearTimeout(this.dieTimeout) this.dieTimeout = setTimeout(()=>{ diff --git a/src/browser/js/app/ipc/index.js b/src/browser/js/app/ipc/index.js index 26b3721f..956d18eb 100644 --- a/src/browser/js/app/ipc/index.js +++ b/src/browser/js/app/ipc/index.js @@ -52,6 +52,7 @@ class Ipc extends EventEmitter { this.reconnect = clearInterval(this.reconnect) this.hearbeat = setInterval(()=>{ + if (!this.connected()) return this.socket.send(`["ping"]`) this.hearbeatTimeout = setTimeout(()=>{ if (this.connected()) this.socket.close() @@ -79,6 +80,7 @@ class Ipc extends EventEmitter { this.hearbeat = clearInterval(this.hearbeat) this.hearbeatTimeout = clearTimeout(this.hearbeatTimeout) + this.dieTimeout = clearTimeout(this.dieTimeout) if (!this.reconnect) { this.reconnect = setInterval(()=>{