From 1cd1a1e5eefc6e7c61ab7c6023fea06515535013 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Tue, 29 Sep 2020 18:13:29 +0100 Subject: improve resilience against GitHub API (#4161) --- test/ufuzz/actions.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'test') 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(); }); } -- cgit v1.2.3