diff --git a/lib/modules/datasource/github-releases/cache/cache-base.spec.ts b/lib/modules/datasource/github-releases/cache/cache-base.spec.ts index fa5e36c8edd6b5d556254df0b69b975fcdb99a07..b0fa4162c66af85b10a786f7e6c06425c8da43e3 100644 --- a/lib/modules/datasource/github-releases/cache/cache-base.spec.ts +++ b/lib/modules/datasource/github-releases/cache/cache-base.spec.ts @@ -345,6 +345,38 @@ describe('modules/datasource/github-releases/cache/cache-base', () => { 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', () => { const cache = new TestCache(http); const ts = cache.getLastReleaseTimestamp({ diff --git a/lib/modules/datasource/github-releases/cache/cache-base.ts b/lib/modules/datasource/github-releases/cache/cache-base.ts index 88cd539ce0bcf2402505d639351406611c0d5cbc..5fa8f50f113b3cc95b9acbf22c1aec10d43d1ea7 100644 --- a/lib/modules/datasource/github-releases/cache/cache-base.ts +++ b/lib/modules/datasource/github-releases/cache/cache-base.ts @@ -1,4 +1,5 @@ import { DateTime, DurationLikeObject } from 'luxon'; +import { logger } from '../../../../logger'; import * as packageCache from '../../../../util/cache/package'; import type { GithubGraphqlResponse, @@ -265,6 +266,19 @@ export abstract class AbstractGithubDatasourceCache< while (pagesRemained > 0 && !stopIteration) { const res = await this.query(baseUrl, variables); 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; }