diff options
Diffstat (limited to 'test/ufuzz/actions.js')
-rw-r--r-- | test/ufuzz/actions.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/test/ufuzz/actions.js b/test/ufuzz/actions.js index 6798aa46..7e9dc21c 100644 --- a/test/ufuzz/actions.js +++ b/test/ufuzz/actions.js @@ -38,6 +38,10 @@ exports.should_stop = function(callback) { }; function read(url, callback) { + var done = function(reply) { + done = function() {}; + callback(reply); + }; var options = parse(url); options.headers = { "Authorization": "Token " + token, @@ -49,7 +53,15 @@ function read(url, callback) { response.on("data", function(chunk) { chunks.push(chunk); }).on("end", function() { - callback(JSON.parse(chunks.join(""))); + var reply; + try { + reply = JSON.parse(chunks.join("")) + } catch (e) {} + done(reply); + }).on("error", function() { + done(); }); + }).on("error", function() { + done(); }); } |