fix(browser-transfer): 재조정에서 checkpoint 삭제가 실패해도 resourceId를 준다
문제: complete 응답을 잃은 뒤 다음 upload()가 재조정해 서버 status
QUARANTINED를 찾았을 때, 로컬 checkpoint 삭제가 한 번 실패하면 runtime이
그 실패를 그대로 돌려준다({UNAVAILABLE, UPLOAD_RECONCILE, retryable:true,
RESUME}). 서버에는 자원이 이미 있는데 이 호출은 resourceId를 잃는다. 같은
상황의 complete 경로는 삭제 실패를 무시하고 성공을 준다.
고친 방법: 재조정의 QUARANTINED 분기도 complete 경로와 같이 삭제 결과와
상관없이 {QUARANTINED, resourceId, replayed:true}를 준다. 남은 행은 다음
upload()나 abort()가 같은 자원으로 정리한다. 설계 문서 4.3절의 같은 규칙
줄에 재조정 경우를 더했다.
위험·한계: 삭제가 계속 실패하는 저장소에서는 행이 남는다. 다음 호출마다
status를 한 번 읽고 같은 resourceId를 replayed로 준다. complete 경로와 같은
한계다.
검증:
- 새 테스트: 고치기 전 {ok:false, UNAVAILABLE, UPLOAD_RECONCILE} (리뷰 X4와
같다), 고친 뒤 {ok:true, QUARANTINED, resource_01, replayed:true}, 행 남음,
다음 호출이 정리
- 영역 단위 테스트 15파일 276건 통과
- check:types(test), eslint(바꾼 파일) 통과
Refs: docs/reviews/2026-11-03-maturity-review/01-adapters-browser-transfer.md 0929/01-02
This commit is contained in:
@@ -390,7 +390,9 @@ complete 결과를 모를 때 클라이언트는 다음처럼 동작한다.
|
||||
resourceId 없이 닫는다(`resumable-upload-runtime.ts` `readCompletedResourceId`).
|
||||
- 서버가 complete를 반영한 뒤 로컬 checkpoint 삭제가 실패해도(IndexedDB 오류,
|
||||
complete 직후 caller abort) `upload()`는 성공을 돌려준다. 남은 행은 다음
|
||||
`upload()`나 `abort()`가 같은 자원으로 정리한다.
|
||||
`upload()`나 `abort()`가 같은 자원으로 정리한다. 응답을 잃은 complete를 다음
|
||||
`upload()`가 재조정해 서버 status `QUARANTINED`를 찾았을 때도 같다
|
||||
(0929/01-02, `reconcileActiveCheckpoint`).
|
||||
|
||||
서버 계약 — complete 진행 중(`ResumableUploadControlPlane.complete` 주석):
|
||||
|
||||
|
||||
@@ -582,12 +582,11 @@ async function reconcileActiveCheckpoint<Capability>(
|
||||
);
|
||||
if (!status.ok) return status;
|
||||
if (status.value.state === "QUARANTINED") {
|
||||
const removed = await removeCheckpoint(
|
||||
dependencies,
|
||||
checkpoint,
|
||||
request.signal,
|
||||
);
|
||||
if (!removed.ok) return removed;
|
||||
// 0929/01-02. The server already holds the resource. A failed local
|
||||
// cleanup leaves the row for the next upload() or abort(), which finds the
|
||||
// same resource; it does not cost this caller the resourceId, as on the
|
||||
// complete path.
|
||||
await removeCheckpoint(dependencies, checkpoint, request.signal);
|
||||
return browserDataSuccess(
|
||||
Object.freeze({
|
||||
kind: "COMPLETED" as const,
|
||||
|
||||
@@ -751,6 +751,56 @@ describe("resumable upload completed-result reporting (01-02)", () => {
|
||||
expect(checkpoints.rows.has(key)).toBe(false);
|
||||
});
|
||||
|
||||
// 0929/01-02 (2026-11-03 리뷰 2절). The reconcile path finds the lost
|
||||
// complete applied; a failed local cleanup must not cost the caller the
|
||||
// resourceId, exactly as on the complete path above.
|
||||
it("reports the reconciled resource even when the local checkpoint cleanup fails", async () => {
|
||||
const harness = committingHarness("LOST");
|
||||
const checkpoints = new MemoryCheckpointStore();
|
||||
const remove = checkpoints.remove.bind(checkpoints);
|
||||
let failRemove = false;
|
||||
checkpoints.remove = async (input) =>
|
||||
failRemove
|
||||
? browserDataFailure("UNAVAILABLE", "UPLOAD_RECONCILE", {
|
||||
retryable: true,
|
||||
recovery: "RESUME",
|
||||
})
|
||||
: await remove(input);
|
||||
const runtime = createResumableUploadRuntime({
|
||||
controlPlane: harness.control,
|
||||
partExecutor: executorFor(harness),
|
||||
checkpoints,
|
||||
mutationLock: noContentionLock,
|
||||
crypto,
|
||||
policy: runtimePolicy({ maxRetries: 0 }),
|
||||
now: () => 1_000,
|
||||
sleep: async () => {},
|
||||
});
|
||||
const key = "upload_key_reconcile_cleanup_fails";
|
||||
expect((await runtime.upload(request(key))).ok).toBe(false);
|
||||
|
||||
failRemove = true;
|
||||
const reconciled = await runtime.upload(request(key));
|
||||
|
||||
expect(reconciled).toEqual({
|
||||
ok: true,
|
||||
value: {
|
||||
state: "QUARANTINED",
|
||||
resourceId: "resource_01",
|
||||
byteLength: 4,
|
||||
replayed: true,
|
||||
},
|
||||
});
|
||||
// The stale row is the next call's to clean up, with the same resource.
|
||||
expect(checkpoints.rows.has(key)).toBe(true);
|
||||
failRemove = false;
|
||||
expect(await runtime.upload(request(key))).toMatchObject({
|
||||
ok: true,
|
||||
value: { resourceId: "resource_01", replayed: true },
|
||||
});
|
||||
expect(checkpoints.rows.has(key)).toBe(false);
|
||||
});
|
||||
|
||||
it("returns the resourceId when abort() finds the lost complete already applied", async () => {
|
||||
const harness = committingHarness("LOST");
|
||||
const checkpoints = new MemoryCheckpointStore();
|
||||
|
||||
Reference in New Issue
Block a user