diff --git a/lib/util/http/github.ts b/lib/util/http/github.ts index a96fad6973222cbde6f187af1997bfb6a1c702e8..69e6718132c51406268e71e70b44880a70ca65e6 100644 --- a/lib/util/http/github.ts +++ b/lib/util/http/github.ts @@ -15,7 +15,8 @@ import { regEx } from '../regex'; import { GotLegacyError } from './legacy'; import { Http, HttpPostOptions, HttpResponse, InternalHttpOptions } from '.'; -let baseUrl = 'https://api.github.com/'; +const githubBaseUrl = 'https://api.github.com/'; +let baseUrl = githubBaseUrl; export const setBaseUrl = (url: string): void => { baseUrl = url; }; @@ -308,7 +309,10 @@ export class GithubHttp extends Http<GithubHttpOptions, GithubHttpOptions> { const result: T[] = []; const { paginate = true } = options; - let count = options.count || 100; + + let optimalCount: null | number = null; + const initialCount = options.count || 100; + let count = initialCount; let limit = options.limit || 1000; let cursor: string = null; @@ -322,6 +326,8 @@ export class GithubHttp extends Http<GithubHttpOptions, GithubHttpOptions> { }); const fieldData = res?.data?.repository?.[fieldName]; if (fieldData) { + optimalCount = count; + const { nodes = [], edges = [], pageInfo } = fieldData; result.push(...nodes); result.push(...edges); @@ -351,6 +357,19 @@ export class GithubHttp extends Http<GithubHttpOptions, GithubHttpOptions> { } } + // See: https://github.com/renovatebot/renovate/issues/12703 + // istanbul ignore if + if ( + optimalCount && + optimalCount < initialCount && // log only shrinked results + baseUrl === githubBaseUrl + ) { + logger.debug( + { optimalCount }, + 'Successful GraphQL query with shrinked pagination size' + ); + } + return result; } }