From f1e12632cfacc1568accbfe19ce0e4ca6702faf2 Mon Sep 17 00:00:00 2001 From: Uno Polak Date: Thu, 16 Jan 2014 22:33:08 -0600 Subject: [PATCH] Trying to fix the stream_status check. --- lib/irc.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/irc.js b/lib/irc.js index 0b6e9dc..d942539 100644 --- a/lib/irc.js +++ b/lib/irc.js @@ -115,8 +115,13 @@ IRC.prototype.start = function () { // log file creation response.on('end', function () { - var json = JSON.parse(body); - __self.streaming = json.stream !== null; + var json = null; + try { + json = JSON.parse(body); + __self.streaming = json.stream !== null; + } catch (err) { + __self.streaming = false; + } if (__self.streaming && !__self.new_file) { // prevent another file from being created while streaming __self.new_file = true; @@ -137,6 +142,7 @@ IRC.prototype.start = function () { file.open(__self.log, 'w'); } else if (!__self.streaming) { __self.new_file = false; + __self.log = ''; } setTimeout(stream_status, 1000); });