diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-09-29 18:13:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-30 01:13:29 +0800 |
commit | 1cd1a1e5eefc6e7c61ab7c6023fea06515535013 (patch) | |
tree | df5701d3d896713e59d5b44af2a9eda9f978093d | |
parent | 1d835ac17de613093a538a4ab72160508197e08c (diff) | |
download | tracifyjs-1cd1a1e5eefc6e7c61ab7c6023fea06515535013.tar.gz tracifyjs-1cd1a1e5eefc6e7c61ab7c6023fea06515535013.zip |
improve resilience against GitHub API (#4161)
-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(); }); } |