test(cache-storage): 조회가 eviction 판정 전에 캐시 목록을 다시 읽는지 고정한다
문제: 조회는 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
This commit is contained in:
@@ -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<string[]> {
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user