refactor(github): improve graphql logging and retries

This commit is contained in:
Rhys Arkins 2018-09-11 11:05:35 +02:00
parent c56362f63b
commit 227d1d4cb7
2 changed files with 12 additions and 2 deletions

View file

@ -78,6 +78,16 @@ async function get(path, options, retries = 5) {
) {
cache[path] = res;
}
// istanbul ignore if
if (method === 'POST' && path === 'graphql') {
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;
} catch (err) {
if (

View file

@ -893,7 +893,7 @@ async function getOpenPrs() {
const prNumbers = [];
// istanbul ignore if
if (!res.data) {
logger.warn({ res }, 'No graphql res.data');
logger.warn({ query, res }, 'No graphql res.data');
return {};
}
for (const pr of res.data.repository.pullRequests.nodes) {
@ -995,7 +995,7 @@ async function getClosedPrs() {
const prNumbers = [];
// istanbul ignore if
if (!res.data) {
logger.warn({ res }, 'No graphql res.data');
logger.warn({ query, res }, 'No graphql res.data');
return {};
}
for (const pr of res.data.repository.pullRequests.nodes) {