From 1f4b929fbe26b9f433ec3e02b4ee658c0cdcb12e Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Fri, 6 Nov 2026 05:18:25 +0900 Subject: [PATCH] =?UTF-8?q?test(service-worker):=20marker=20=EC=9D=BD?= =?UTF-8?q?=EA=B8=B0=20=EC=83=81=ED=95=9C=20test=EA=B0=80=205=EC=B4=88?= =?UTF-8?q?=EB=B3=B4=EB=8B=A4=20=EA=B8=B4=20=EC=83=81=ED=95=9C=EC=9D=84=20?= =?UTF-8?q?=EC=9E=A1=EB=8A=94=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제 "bounds a stream that never produces a chunk"는 가짜 시계를 5초씩 최대 4번 넘긴 뒤 활성화가 끝났는지 본다(`ce191be`, 1101/10-07). 그래서 marker 읽기 상한(`ACTIVATION_MARKER_READ_DEADLINE_MS`, 5초)을 20초까지 올려도 통과한다. 실제 시계로 기다리던 수정 전 test는 10초 test 제한에서 실패했다. 상한을 15초로 올린 리뷰 변이 06-R3에서 64건이 모두 통과했다. 고른 방법과 버린 대안 - 반복을 지우고 `advanceTimersByTimeAsync(5_000)`를 한 번만 부른다(리뷰 (가)). 이 fixture는 캐시가 현재 캐시 하나라 marker를 한 번만 읽는다 (`highestMarkedCache`는 현재 캐시를 건너뛴다). 상한이 1 ms만 길어도 활성화가 끝나지 않아 `settled` 단언이 실패한다. 수정 전 test(10초 이상만 검출)보다 강하다. 가짜 시계는 그대로라 실제 대기는 돌아오지 않는다. `cancels >= 1` 단언도 그대로다. - 버린 대안: 상수를 `SERVICE_WORKER_BOUNDS`로 옮기고 그 값만큼 넘기기 (리뷰 (나)). test가 상수를 따라가므로 계약 모듈에서 값을 15초로 올리면 그대로 통과한다. 약점이 자리만 옮긴다. 계약 모듈 변경이라 워커·페이지 두 realm 검사도 다시 돌아야 하고, 리뷰 변이 06-R3도 이 커밋에 그대로 적용되지 않는다. - 숫자 5_000이 test에 한 번 더 적힌다. 이 test가 지키는 값이 그것이라 일부러 둔다. 위험·한계 - fixture가 marker를 여러 번 읽게 바뀌면 이 test가 실패한다. 그때는 읽는 횟수만큼 정확히 넘긴다(리뷰 재검토 조건). - 상한을 줄이는 변경은 잡지 않는다. 수정 전 test도 잡지 않았다. - 한 번의 tick으로 끝나려면 deadline timer가 tick 전에 걸려 있어야 한다. `onActivate()`부터 `setTimeout`까지는 바로 끝나는 async mock뿐이고, `advanceTimersByTimeAsync`는 시계를 넘기기 전에 실제 macrotask 하나를 양보한다(fake-timers `tickAsync`). 코드로 본 판단이고 이 커밋으로는 아직 돌리지 않았다. 검증 - desktop batch에서 확인: node scripts/run-vitest.ts run tests/unit/service-worker-runtime.test.ts - 테스트만 바꾼 커밋이라 RED는 없다. 대신 변이 둘에서 이 test가 실패해야 한다: 리뷰 06-R3(상한 15_000), 완료 기준 변이(상한 5_001). - 무변이에서는 64건이 통과한다. Refs: 1106/06-02 --- tests/unit/service-worker-runtime.test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/unit/service-worker-runtime.test.ts b/tests/unit/service-worker-runtime.test.ts index 930496cc..a88e9a57 100644 --- a/tests/unit/service-worker-runtime.test.ts +++ b/tests/unit/service-worker-runtime.test.ts @@ -2007,6 +2007,9 @@ describe("SW-01 the activation marker read is bounded in bytes", () => { // 1101/10-07. The read deadline is the runtime's own 5 s constant. The // clock is faked, so the test passes the deadline instead of waiting it // out; without a deadline the activation never settles and this fails. + // 1106/06-02. This fixture has one cache, the current one, so activation + // reads one marker and waits for one deadline. The clock advances exactly + // 5 s once: a longer deadline, even by 1 ms, leaves it unsettled here. vi.useFakeTimers(); try { let cancels = 0; @@ -2026,10 +2029,7 @@ describe("SW-01 the activation marker read is bounded in bytes", () => { .finally(() => { settled = true; }); - // One read deadline per marker probe. - for (let probe = 0; probe < 4 && !settled; probe += 1) { - await vi.advanceTimersByTimeAsync(5_000); - } + await vi.advanceTimersByTimeAsync(5_000); expect(settled).toBe(true); await expect(activation).resolves.toBeTypeOf("number");