From 9e2dbb2a9a2514b0072c1c78f70ed635e01b2d67 Mon Sep 17 00:00:00 2001 From: Harlan Wilton Date: Wed, 30 Sep 2026 20:26:40 +1000 Subject: [PATCH] fix(ci): treat the default trending board as an alias --- scripts/lib/edge-cache-check.ts | 12 +++++++++--- test/unit/edge-cache-check.test.ts | 12 ++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/scripts/lib/edge-cache-check.ts b/scripts/lib/edge-cache-check.ts index 84df578e..175bfc07 100644 --- a/scripts/lib/edge-cache-check.ts +++ b/scripts/lib/edge-cache-check.ts @@ -11,10 +11,13 @@ * 3. An agent that asks for Markdown still gets the 307 to the `.md` URL. * 4. A request that carries a session cookie gets the anonymous render, and * the page tells the browser to load the session itself. - * 5. Every page is stored under its own key: pages that differ only by query - * string render a different title or canonical URL. + * 5. Every board is stored under its own key: boards that differ only by query + * string render a different title or canonical URL. The bare path and the + * default range are one board, so they may share both. */ +import { DEFAULT_TRENDING_RANGE } from '../../shared/trending-range' + /** The pages `nuxt.config.ts` gives an `edgeCache` rule. Each query is its own cache key. */ export const EDGE_CACHED_PATHS = ['/skills/trending', '/skills/trending?range=month', '/skills/trending?range=all'] @@ -28,6 +31,9 @@ const BROWSER_HEADERS = { /** Opaque on purpose: the page must not read it, so it never needs to unseal. */ const SESSION_COOKIE = 'nuxt-session=edge-cache-check' +/** The bare path and the default range name one board, so one canonical URL. */ +const DEFAULT_BOARD_ALIASES = new Set(['/skills/trending', `/skills/trending?range=${DEFAULT_TRENDING_RANGE}`]) + /** `cf-cache-status` values that mean the edge answered without the Worker. */ const SERVED_FROM_CACHE = new Set(['HIT', 'STALE', 'UPDATING']) @@ -241,7 +247,7 @@ export async function checkEdgeCache(dependencies: EdgeCacheCheckDependencies): } for (const [identity, sharing] of identities) { - if (sharing.length > 1) + if (sharing.length > 1 && !sharing.every(path => DEFAULT_BOARD_ALIASES.has(path))) failures.push({ _tag: 'shared-cache-entry', paths: sharing, identity }) } diff --git a/test/unit/edge-cache-check.test.ts b/test/unit/edge-cache-check.test.ts index bacc60bf..058b0748 100644 --- a/test/unit/edge-cache-check.test.ts +++ b/test/unit/edge-cache-check.test.ts @@ -93,6 +93,18 @@ describe('checkEdgeCache', () => { }) }) + it('passes when the bare path and the default range render one board', async () => { + const paths = ['/skills/trending', '/skills/trending?range=month', '/skills/trending?range=all'] + const result = await run(edge({ + anonymous: (path, count) => ({ + body: page(null, false, path === '/skills/trending?range=all' ? path : '/skills/trending'), + headers: { 'cf-cache-status': count === 1 ? 'MISS' : 'HIT' }, + }), + }), paths) + + expect(result._tag).toBe('passed') + }) + it('retries a transient non-200 once before it fails a board', async () => { const inner = edge() let failedOnce = false