From 43820167db30dea9ead081f81a197be4631f167f Mon Sep 17 00:00:00 2001
From: Gopalakrishna Palem <KrishnaPG@users.noreply.github.com>
Date: Sun, 5 Jan 2020 12:04:37 +0530
Subject: [PATCH 1/4] Handle client connection errors

When the Tendermint server is killed / crashed, it is crashing the ABCI proxy app, due to  the connection error event. This fixes the issue.
---
 src/server.js | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/server.js b/src/server.js
index cea38bd..880c401 100644
--- a/src/server.js
+++ b/src/server.js
@@ -56,6 +56,7 @@ function createServer (app) {
         fail(err)
       }
     })
+    conn.on('error', err => { });
   })
 
   return server

From f2bc0cb00253d45627d9be9a4a0fe35b8c791e6b Mon Sep 17 00:00:00 2001
From: Gopalakrishna Palem <KrishnaPG@users.noreply.github.com>
Date: Sun, 5 Jan 2020 12:08:39 +0530
Subject: [PATCH 2/4] make the style gods happy

---
 src/server.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/server.js b/src/server.js
index 880c401..ef0dd33 100644
--- a/src/server.js
+++ b/src/server.js
@@ -56,7 +56,7 @@ function createServer (app) {
         fail(err)
       }
     })
-    conn.on('error', err => { });
+    conn.on('error', err => {})
   })
 
   return server

From e15b88d31497801f024a09d95f10596bb3f03eca Mon Sep 17 00:00:00 2001
From: Gopalakrishna Palem <KrishnaPG@users.noreply.github.com>
Date: Sun, 5 Jan 2020 12:14:08 +0530
Subject: [PATCH 3/4] workaround for handle-callback-err

In this case, the client (the Tendermint backend) closed the connection, and stream already destroyed. We just have to handle the error, since NodeJS crashes otherwise. But nothing much to do inside the handler. So its just empty. If the CI fails again, nothing I can do beyond this.
---
 src/server.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/server.js b/src/server.js
index ef0dd33..fab5878 100644
--- a/src/server.js
+++ b/src/server.js
@@ -56,7 +56,7 @@ function createServer (app) {
         fail(err)
       }
     })
-    conn.on('error', err => {})
+    conn.on('error', () => {/* by this point the conn.stream is destroyed, nothing else to do !!*/})
   })
 
   return server

From e119b58a7c43b6334112a6ed455cb3eebb178c08 Mon Sep 17 00:00:00 2001
From: Gopalakrishna Palem <KrishnaPG@users.noreply.github.com>
Date: Sun, 5 Jan 2020 12:16:38 +0530
Subject: [PATCH 4/4] Style changes

standard: Use JavaScript Standard Style (https://standardjs.com)
  /home/circleci/js-abci/src/server.js:59:28: Requires a space after '{'
  /home/circleci/js-abci/src/server.js:59:29: Expected space or tab before '*/' in comment.
  /home/circleci/js-abci/src/server.js:59:99: Requires a space before '}'
---
 src/server.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/server.js b/src/server.js
index fab5878..3729d1f 100644
--- a/src/server.js
+++ b/src/server.js
@@ -56,7 +56,7 @@ function createServer (app) {
         fail(err)
       }
     })
-    conn.on('error', () => {/* by this point the conn.stream is destroyed, nothing else to do !!*/})
+    conn.on('error', () => { /* by this point the conn.stream is destroyed, nothing else to do !! */ })
   })
 
   return server