Skip to content

Conversation

@WcaleNieWolny
Copy link
Contributor

@WcaleNieWolny WcaleNieWolny commented Jan 21, 2026

Summary (AI generated)

  • Added fetchWithRetry helper function with exponential backoff for build request API calls
  • Retries failed requests up to 3 times with delays of 1s, 3s, and 5s
  • Only retries on server errors (5xx) or network failures; client errors (4xx) are not retried
  • Logs warnings for each failed attempt and info for retry delays

Motivation (AI generated)

Build requests to the Capgo backend can occasionally fail due to transient network issues or temporary server unavailability. Without retry logic, users experience immediate failures that require manual re-running of the build command. This change improves reliability by automatically retrying failed requests before giving up.

Business Impact (AI generated)

  • Improved User Experience: Users will see fewer spurious build failures due to transient network/server issues
  • Reduced Support Load: Fewer users reporting "build request failed" errors that resolve on retry
  • Increased Build Success Rate: Automatic retries help builds succeed even during brief infrastructure hiccups

Test Plan (AI generated)

  • Verify normal build requests work without changes (no retry needed)
  • Verify 4xx errors are NOT retried and fail immediately
  • Verify 5xx errors trigger retries with appropriate delays
  • Verify network failures trigger retries
  • Verify max retries (3) is respected and final failure is reported correctly
  • Verify silent mode suppresses retry logs

Generated with AI

Summary by CodeRabbit

  • Improvements
    • Enhanced request reliability for build operations with automatic retry logic for network failures and server errors
    • Improved error handling and logging for build request failures

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 21, 2026

📝 Walkthrough

Walkthrough

A new internal fetchWithRetry helper function was added to handle HTTP requests with exponential backoff retry logic for server errors and network failures. The requestBuildInternal function was updated to use this new helper instead of direct fetch calls.

Changes

Cohort / File(s) Summary
Retry Logic Enhancement
src/build/request.ts
Added internal fetchWithRetry helper with exponential backoff (1s, 3s, 5s delays) for handling 5xx server errors and network failures; updated requestBuildInternal to use the new helper with configurable retry counts and silent logging control

Sequence Diagram

sequenceDiagram
    participant Client as requestBuildInternal
    participant Retry as fetchWithRetry
    participant Server as HTTP Server
    
    Client->>Retry: POST /build/request (maxRetries=3, silent=false)
    Retry->>Server: Attempt 1
    Server-->>Retry: 5xx Error
    Note over Retry: Log error, wait 1s
    Retry->>Server: Attempt 2
    Server-->>Retry: 5xx Error
    Note over Retry: Log error, wait 3s
    Retry->>Server: Attempt 3
    Server-->>Retry: 5xx Error
    Note over Retry: Log error, wait 5s
    Retry->>Server: Attempt 4 (final)
    Server-->>Retry: 5xx Error
    Retry-->>Client: Throw consolidated error
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Hops with joy through retry's dance,
Exponential backoff gives each chance,
When servers stumble, five-hundred-fold,
Patient rabbits don't lose their hold!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: adding retry logic with exponential backoff for build requests, which is the primary focus of this changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link

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.

2 participants