mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-14 16:46:25 +00:00
fix(github): Shrink pages for specific types of errors (#16388)
This commit is contained in:
parent
b5df686fb7
commit
1454b602fc
2 changed files with 46 additions and 0 deletions
|
@ -345,6 +345,38 @@ describe('modules/datasource/github-releases/cache/cache-base', () => {
|
||||||
expect(packageCache.set).not.toHaveBeenCalled();
|
expect(packageCache.set).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('shrinks for some of graphql errors', async () => {
|
||||||
|
packageCache.get.mockResolvedValueOnce({
|
||||||
|
items: {},
|
||||||
|
createdAt: t3,
|
||||||
|
updatedAt: t3,
|
||||||
|
});
|
||||||
|
responses = [
|
||||||
|
{
|
||||||
|
statusCode: 200,
|
||||||
|
headers: {},
|
||||||
|
body: {
|
||||||
|
errors: [
|
||||||
|
{ message: 'Something went wrong while executing your query.' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
resp([{ name: 'v3', createdAt: t3, foo: 'ccc' }], true),
|
||||||
|
resp([{ name: 'v2', createdAt: t2, foo: 'bbb' }], true),
|
||||||
|
resp([{ name: 'v1', createdAt: t1, foo: 'aaa' }]),
|
||||||
|
];
|
||||||
|
const cache = new TestCache(http, { resetDeltaMinutes: 0 });
|
||||||
|
|
||||||
|
const res = await cache.getItems({ packageName: 'foo/bar' });
|
||||||
|
|
||||||
|
expect(sortItems(res)).toMatchObject([
|
||||||
|
{ version: 'v1', bar: 'aaa' },
|
||||||
|
{ version: 'v2', bar: 'bbb' },
|
||||||
|
{ version: 'v3', bar: 'ccc' },
|
||||||
|
]);
|
||||||
|
expect(packageCache.set).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
it('finds latest release timestamp correctly', () => {
|
it('finds latest release timestamp correctly', () => {
|
||||||
const cache = new TestCache(http);
|
const cache = new TestCache(http);
|
||||||
const ts = cache.getLastReleaseTimestamp({
|
const ts = cache.getLastReleaseTimestamp({
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { DateTime, DurationLikeObject } from 'luxon';
|
import { DateTime, DurationLikeObject } from 'luxon';
|
||||||
|
import { logger } from '../../../../logger';
|
||||||
import * as packageCache from '../../../../util/cache/package';
|
import * as packageCache from '../../../../util/cache/package';
|
||||||
import type {
|
import type {
|
||||||
GithubGraphqlResponse,
|
GithubGraphqlResponse,
|
||||||
|
@ -265,6 +266,19 @@ export abstract class AbstractGithubDatasourceCache<
|
||||||
while (pagesRemained > 0 && !stopIteration) {
|
while (pagesRemained > 0 && !stopIteration) {
|
||||||
const res = await this.query(baseUrl, variables);
|
const res = await this.query(baseUrl, variables);
|
||||||
if (res instanceof Error) {
|
if (res instanceof Error) {
|
||||||
|
if (
|
||||||
|
res.message.startsWith(
|
||||||
|
'Something went wrong while executing your query.' // #16343
|
||||||
|
) &&
|
||||||
|
variables.count > 30
|
||||||
|
) {
|
||||||
|
logger.warn(
|
||||||
|
`GitHub datasource cache: shrinking GraphQL page size due to error`
|
||||||
|
);
|
||||||
|
pagesRemained *= 2;
|
||||||
|
variables.count = Math.floor(variables.count / 2);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
throw res;
|
throw res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue