From f19eff92ced8fbbbca7405cf9eced57580ff28b1 Mon Sep 17 00:00:00 2001 From: Sergei Zharinov Date: Fri, 20 Oct 2023 02:47:21 -0300 Subject: [PATCH] fix(github): Reconcile entire GraphQL pages (#25311) --- .../graphql/cache-strategies/abstract-cache-strategy.ts | 6 +++++- .../cache-strategies/memory-cache-strategy.spec.ts | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/util/github/graphql/cache-strategies/abstract-cache-strategy.ts b/lib/util/github/graphql/cache-strategies/abstract-cache-strategy.ts index 98ddffcd3f342f..1b8a1288026b01 100644 --- a/lib/util/github/graphql/cache-strategies/abstract-cache-strategy.ts +++ b/lib/util/github/graphql/cache-strategies/abstract-cache-strategy.ts @@ -110,9 +110,13 @@ export abstract class AbstractGithubGraphqlCacheStrategy< // If we reached previously stored item that is stabilized, // we assume the further pagination will not yield any new items. + // + // However, we don't break the loop here, allowing to reconcile + // the entire page of items. This protects us from unusual cases + // when release authors intentionally break the timeline. Therefore, + // while it feels appealing to break early, please don't do that. if (oldItem && this.isStabilized(oldItem)) { isPaginationDone = true; - break; } // Check if item is new or updated diff --git a/lib/util/github/graphql/cache-strategies/memory-cache-strategy.spec.ts b/lib/util/github/graphql/cache-strategies/memory-cache-strategy.spec.ts index 4dcf3d1ac7927a..5d693996290f03 100644 --- a/lib/util/github/graphql/cache-strategies/memory-cache-strategy.spec.ts +++ b/lib/util/github/graphql/cache-strategies/memory-cache-strategy.spec.ts @@ -133,7 +133,7 @@ describe('util/github/graphql/cache-strategies/memory-cache-strategy', () => { expect(isPaginationDone).toBe(true); }); - it('reconciles only not stabilized items in page', async () => { + it('reconciles entire page', async () => { const oldItems = { '1': { releaseTimestamp: isoTs('2020-01-01 00:00'), version: '1' }, '2': { releaseTimestamp: isoTs('2020-01-01 01:00'), version: '2' }, @@ -161,9 +161,9 @@ describe('util/github/graphql/cache-strategies/memory-cache-strategy', () => { expect(isPaginationDone).toBe(true); expect(memCache.get('github-graphql-cache:foo:bar')).toMatchObject({ items: { - '1': { releaseTimestamp: isoTs('2020-01-01 00:00') }, - '2': { releaseTimestamp: isoTs('2020-01-01 01:00') }, - '3': { releaseTimestamp: isoTs('2020-01-01 02:00') }, + '1': { releaseTimestamp: isoTs('2022-12-31 10:00') }, + '2': { releaseTimestamp: isoTs('2022-12-31 11:00') }, + '3': { releaseTimestamp: isoTs('2022-12-31 12:00') }, '4': { releaseTimestamp: isoTs('2022-12-31 13:00') }, }, });