aboutsummaryrefslogtreecommitdiff
path: root/test/ufuzz/actions.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-09-29 18:13:29 +0100
committerGitHub <noreply@github.com>2020-09-30 01:13:29 +0800
commit1cd1a1e5eefc6e7c61ab7c6023fea06515535013 (patch)
treedf5701d3d896713e59d5b44af2a9eda9f978093d /test/ufuzz/actions.js
parent1d835ac17de613093a538a4ab72160508197e08c (diff)
downloadtracifyjs-1cd1a1e5eefc6e7c61ab7c6023fea06515535013.tar.gz
tracifyjs-1cd1a1e5eefc6e7c61ab7c6023fea06515535013.zip
improve resilience against GitHub API (#4161)
Diffstat (limited to 'test/ufuzz/actions.js')
-rw-r--r--test/ufuzz/actions.js14
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();
});
}