Skip to content

fix(bundle): add retry loop to streamUrlToFile for transport failures#23

Open
crypticsaiyan wants to merge 1 commit into
TestSprite:mainfrom
crypticsaiyan:fix/stream-url-to-file-retry
Open

fix(bundle): add retry loop to streamUrlToFile for transport failures#23
crypticsaiyan wants to merge 1 commit into
TestSprite:mainfrom
crypticsaiyan:fix/stream-url-to-file-retry

Conversation

@crypticsaiyan

Copy link
Copy Markdown

Summary

streamUrlToFile promised a "bounded retry on transport failures" in its JSDoc but made only one attempt. Transient network blips during downloads caused hard failures, forcing manual re-runs.

The Fix

  • Bounded Retry Loop: Added a 3-attempt loop (STREAM_URL_MAX_RETRIES) with a 1s delay for transport or mid-stream pipeline errors.
  • Smart Fail-Fast: HTTP 4xx/5xx errors (ApiError) skip retries and fail immediately (e.g., expired presigned URLs will not recover).
  • Testability: Added an optional deps.sleep injection for deterministic testing without real-world delays.

Testing

Added 5 tests to src/lib/bundle.test.ts verifying:

  • First-attempt success
  • Transient recovery (retry-then-succeed)
  • Retry exhaustion (TransportError)
  • Fast failure on HTTP errors (ApiError)
  • Correct injected sleep calls between attempts

Files Changed:

  • src/lib/bundle.ts
  • src/lib/bundle.test.ts

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.

1 participant