Skip to content

Spork: add bounded retry policy for transient step-content download failures#301

Merged
rkttu merged 4 commits into
mainfrom
copilot/add-retry-logic-file-download
Jul 9, 2026
Merged

Spork: add bounded retry policy for transient step-content download failures#301
rkttu merged 4 commits into
mainfrom
copilot/add-retry-logic-file-download

Conversation

Copilot AI commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Step-content downloads in Spork currently fail fast on transient network conditions. This change adds bounded retries with jitter-free fixed backoff aligned to the requirement: up to 2 extra attempts after the first try, waiting 1s then 3s.

  • Retry orchestration in download stage

    • StepsPlayer.DownloadContentAsync now routes content fetches through a retry wrapper.
    • Retry is applied only to transient failures; non-transient errors still fail immediately.
    • Maximum attempts are fixed at 3 total (initial + 2 retries) with delays [1s, 3s].
  • Transient error classification

    • Added centralized transient detection in StepsPlayer:
      • HttpRequestException with 408, 429, or 5xx
      • TaskCanceledException, TimeoutException, IOException
      • Nested inner exceptions are recursively evaluated.
  • Cancellation behavior

    • Cancellation-requested OperationCanceledException is propagated directly (no retry), including during retry-delay windows.
  • Targeted unit coverage

    • Added focused tests for transient classification behavior (e.g., 503 => retryable, 404 => non-retryable).
private static readonly TimeSpan[] DownloadRetryDelays =
    [TimeSpan.FromSeconds(1d), TimeSpan.FromSeconds(3d)];

var hasMoreRetry = attempt < DownloadRetryDelays.Length;
if (!hasMoreRetry || !IsTransientDownloadException(ex))
    throw;

@CLAassistant

CLAassistant commented Jul 9, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ rkttu
❌ Copilot
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI changed the title [WIP] Add retry logic for file download errors Spork: add bounded retry policy for transient step-content download failures Jul 9, 2026
Copilot finished work on behalf of rkttu July 9, 2026 03:46
Copilot AI requested a review from rkttu July 9, 2026 03:46
일시적 실패 재시도 로직의 분류 정확도를 높이고, "재시도하지 않을 종류가 실제로
재시도되지 않는지"를 루프 동작 수준까지 검증한다.

분류기(StepsPlayer.IsTransientDownloadException)
- 소켓 수준 오류를 명시적으로 처리: 래핑되지 않은 SocketException도 일시적으로 취급
  (HttpClient는 보통 HttpRequestException[StatusCode 없음]/IOException으로 래핑하지만,
   다른 다운로드 계층 대비).
- 상태 코드 기준 실패 판정을 정밀화: 기존 "모든 5xx 재시도"에서 재시도 대상 코드만
  선별(408/429/500/502/503/504). 501(Not Implemented)·505 등 영구성 5xx는 재시도하지
  않고 즉시 실패로 건너뛴다(IsRetryableStatusCode 헬퍼로 분리).

테스트(Spork.Test)
- StepsPlayerSocketFailureTests: 순수 SocketException 6종(리셋/거부/중단/타임아웃/
  도달불가/DNS) + 래핑 형태가 재시도 대상으로 분류되는지 검증.
- StepsPlayerStatusCodeClassificationTests: 재시도 대상 vs 건너뜀(4xx + 영구성 5xx)
  상태 코드, 그리고 비일시적 예외 타입이 건너뛰어지는지 검증.
- StepsPlayerRetryLoopTests: 실제 재시도 루프 시도 횟수 검증 — 영구성 코드/비일시적
  예외는 1회(재시도 없음), 일시적 오류는 최대 3회, 중간 성공 시 즉시 중단.

빌드 경고 0, Spork.Test 42개 통과.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@rkttu
rkttu marked this pull request as ready for review July 9, 2026 13:38
Copilot AI review requested due to automatic review settings July 9, 2026 13:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a bounded retry policy to Spork step-content downloading so transient network/IO failures don’t fail fast, and introduces targeted unit tests to validate transient classification + retry-loop behavior.

Changes:

  • Route StepsPlayer.DownloadContentAsync through a new retry wrapper with fixed backoff delays (1s, then 3s; max 3 total attempts).
  • Add centralized transient-failure detection (IsTransientDownloadException + status code classification).
  • Add unit tests covering retryable/non-retryable status codes, socket/IO-level failures, and retry-loop attempt counts.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Spork.App/Steps/Implementations/StepsPlayer.cs Implements retry loop + transient exception/status-code classification for step content downloads.
src/Spork.Test/StepsPlayerRetryLoopTests.cs Verifies retry loop attempt limits and stop-on-success behavior.
src/Spork.Test/StepsPlayerStatusCodeClassificationTests.cs Tests HTTP status code-based transient classification.
src/Spork.Test/StepsPlayerSocketFailureTests.cs Tests socket/IO failure classification including inner-exception recursion.
src/Spork.Test/StepsPlayerTransientDownloadTests.cs Adds basic transient classification tests for a few representative exception types.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +22 to +23
[TestClass]
public class StepsPlayerRetryLoopTests
@rkttu
rkttu merged commit fb6fff5 into main Jul 9, 2026
10 of 11 checks passed
@rkttu
rkttu deleted the copilot/add-retry-logic-file-download branch July 9, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[개선] 파일 다운로드 도중 재시도가 필요한 항목들에 대한 처리 추가

4 participants