From 3bfe6a85809da7e41bc691c58fe0c026548d4858 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Wed, 4 Nov 2026 21:01:49 +0900 Subject: [PATCH] =?UTF-8?q?test(cache-storage):=20=EC=A1=B0=ED=9A=8C?= =?UTF-8?q?=EA=B0=80=20eviction=20=ED=8C=90=EC=A0=95=20=EC=A0=84=EC=97=90?= =?UTF-8?q?=20=EC=BA=90=EC=8B=9C=20=EB=AA=A9=EB=A1=9D=EC=9D=84=20=EB=8B=A4?= =?UTF-8?q?=EC=8B=9C=20=EC=9D=BD=EB=8A=94=EC=A7=80=20=EA=B3=A0=EC=A0=95?= =?UTF-8?q?=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제: 조회는 cache 이름 목록을 pointer보다 먼저 읽는다. 그 사이 다른 탭의 activation이 pointer를 새 캐시로 옮기면 목록에 그 캐시가 없다. 코드는 목록을 한 번 더 읽고서야 STORAGE_EVICTED를 낸다 (1101/02-04 ⑤, N39). 이 재확인을 지워도 테스트가 모두 통과했다. 빠지면 방금 배포한 release의 첫 조회가 "지워졌다"로 끝나고 REHYDRATE로 간다. 고른 방법: 첫 keys()만 배포 전 목록을 돌려주는 저장소로 r2 활성화 뒤 조회한다. adapter는 만들 때 keys를 잡아 두므로 저장소 하위 클래스로 한 번만 낡은 답을 준다. 위험·한계: 테스트만 바꾼다. 1101/02-04의 N38(host storageArea 비교)은 pulse wire 값을 만드는 하네스가 필요해 이번에 하지 않았다. 검증: N39 변이를 넣으면 이 테스트가 STORAGE_EVICTED로 실패하고(cache 단위 3파일 + tests/recipes 71건 중 1건), 되돌리면 같은 파일 14건 통과. check:types:test, eslint 통과. Refs: docs/reviews/2026-11-03-maturity-review/02-adapters-browser-files-cache.md 1101/02-04 --- .../unit/public-response-cache-repair.test.ts | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/unit/public-response-cache-repair.test.ts b/tests/unit/public-response-cache-repair.test.ts index 692cc95b..554ee1b6 100644 --- a/tests/unit/public-response-cache-repair.test.ts +++ b/tests/unit/public-response-cache-repair.test.ts @@ -584,6 +584,33 @@ describe("public cache pointer after a policy change or damage (0929/02-01)", () ).toMatchObject({ ok: true, value: expect.anything() }); }); + // 2026-11-01 02-04 (N39). The cache name list is read before the pointer. + // An activation in between moves the pointer to a cache that list does not + // have yet; the lookup lists again rather than report it evicted. + it("lists caches again before it reports the active release evicted", async () => { + // The adapter captures `keys` when it is built, so the stale answer is + // armed through the storage itself. + class StaleOnceCacheStorage extends MemoryCacheStorage { + staleNames: string[] | null = null; + override async keys(): Promise { + const stale = this.staleNames; + this.staleNames = null; + return stale ?? (await super.keys()); + } + } + const cacheStorage = new StaleOnceCacheStorage(); + const policy = policyRetaining(1); + const adapter = adapterFor(cacheStorage, policy); + expect(await deploy(adapter, "r1", policy)).toMatchObject({ ok: true }); + const namesBeforeR2 = await cacheStorage.keys(); + expect(await deploy(adapter, "r2", policy)).toMatchObject({ ok: true }); + cacheStorage.staleNames = namesBeforeR2; + + expect( + await adapter.responses.matchActiveExact({ absoluteUrl: assetUrl("r2") }), + ).toMatchObject({ ok: true, value: expect.anything() }); + }); + it("still stops activation when the pointer read fails transiently", async () => { const cacheStorage = new MemoryCacheStorage(); const policy = policyRetaining(1);