diff --git a/lib/platform/github/gh-got-wrapper.js b/lib/platform/github/gh-got-wrapper.js index cb827e5898e39b07c25b4976b9b3ff516ac0d8f6..3d09a0ccdfc8817c746c77236f067b40baeeb827 100644 --- a/lib/platform/github/gh-got-wrapper.js +++ b/lib/platform/github/gh-got-wrapper.js @@ -80,15 +80,12 @@ async function get(path, options, retries = 5) { } // istanbul ignore if if (method === 'POST' && path === 'graphql') { - if (res.body) { - res.body = JSON.parse(res.body); - if (res.body.errors && retries > 0) { - logger.info('Retrying graphql query'); - return get(path, opts, 0); - } - if (res.body.data && retries === 0) { - logger.info('Recovered graphql query'); - } + if (res.errors && retries > 0) { + logger.info('Retrying graphql query'); + return get(path, opts, 0); + } + if (res.data && retries === 0) { + logger.info('Recovered graphql query'); } } return res; diff --git a/lib/platform/github/index.js b/lib/platform/github/index.js index a040e6681d644893a4b892b4c2a1964d3f0d3a57..eb97aea0e6793096465f80ec42eefe8ea230fa53 100644 --- a/lib/platform/github/index.js +++ b/lib/platform/github/index.js @@ -889,7 +889,7 @@ async function getOpenPrs() { body: JSON.stringify({ query }), json: false, }; - const res = (await get.post(url, options)).body; + const res = JSON.parse((await get.post(url, options)).body); const prNumbers = []; // istanbul ignore if if (!res.data) { @@ -991,7 +991,7 @@ async function getClosedPrs() { body: JSON.stringify({ query }), json: false, }; - const res = (await get.post(url, options)).body; + const res = JSON.parse((await get.post(url, options)).body); const prNumbers = []; // istanbul ignore if if (!res.data) { @@ -1294,7 +1294,7 @@ async function getVulnerabilityAlerts() { }; let alerts = []; try { - const res = (await get.post(url, options)).body; + const res = JSON.parse((await get.post(url, options)).body); if (res.data.repository.vulnerabilityAlerts) { alerts = res.data.repository.vulnerabilityAlerts.edges.map( edge => edge.node