From bda05cee1f0d4e9279cc70ac236ea1b48b75f480 Mon Sep 17 00:00:00 2001 From: Mitsuhiro Koga Date: Thu, 30 Jun 2016 13:59:00 +0900 Subject: [PATCH 1/2] call callback on error --- src/chatwork.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/chatwork.coffee b/src/chatwork.coffee index 685937e..4de7ee6 100644 --- a/src/chatwork.coffee +++ b/src/chatwork.coffee @@ -242,4 +242,5 @@ class ChatworkStreaming extends EventEmitter request.on "error", (err) -> logger.error "Chatwork request error: #{err}" + callback err, {} From 67d3fbf0e0483810dcc6c740976f97c155b8ad8c Mon Sep 17 00:00:00 2001 From: Mitsuhiro Koga Date: Thu, 30 Jun 2016 20:33:13 +0900 Subject: [PATCH 2/2] check for the existence of callback --- src/chatwork.coffee | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/chatwork.coffee b/src/chatwork.coffee index 4de7ee6..f2b4d24 100644 --- a/src/chatwork.coffee +++ b/src/chatwork.coffee @@ -236,11 +236,13 @@ class ChatworkStreaming extends EventEmitter response.on "error", (err) -> logger.error "Chatwork HTTPS response error: #{err}" - callback err, {} + if callback + callback err, {} request.end body, 'binary' request.on "error", (err) -> logger.error "Chatwork request error: #{err}" - callback err, {} + if callback + callback err, {}