Skip to content

feat(web): add Connect-RPC retry interceptor and resilient polling/upload/download - #923

Merged
kyasbal merged 2 commits into
GoogleCloudPlatform:mainfrom
kyasbal:push-oztswsumowus
Aug 28, 2026
Merged

kyasbal merged 2 commits into
GoogleCloudPlatform:mainfrom
kyasbal:push-oztswsumowus

Conversation

@kyasbal

@kyasbal kyasbal commented Aug 28, 2026

Copy link
Copy Markdown
Member

Summary

Adds automatic retry mechanisms across Connect-RPC unary calls, chunked file upload/download, and legacy polling to handle transient failures (HTTP 502 Bad Gateway, 503 Service Unavailable, 504 Gateway Timeout, and network connection drops).

Key Changes

  1. Retry Interceptor (retry.interceptor.ts):
    • Implements createRetryInterceptor with exponential backoff and jitter.
    • Automatically retries idempotent unary RPCs on transient errors (Code.Unavailable and fetch errors).
    • Prevents double retries on chunked operations by delegating chunk-specific retries to their respective managers.
  2. Chunked Uploader (chunked-uploader.ts):
    • Retries failed chunk uploads up to 10 attempts (DEFAULT_CHUNK_MAX_RETRIES = 10) with backoff.
    • Fails immediately on non-retryable errors (e.g., 400 Bad Request) without unnecessary retries.
  3. Chunked Download (backend-api.service.ts):
    • Retries getInspectionDataChunk downloads up to 10 attempts (DEFAULT_CHUNK_MAX_RETRIES = 10) using RxJS retry and exponential backoff.
  4. Legacy Polling Interceptor (legacy-polling.interceptor.ts):
    • Reuses common delayWithSignal utility.
    • Tolerates up to 5 consecutive transient errors during OpenWorkbench and FilterTimeline polling before giving up.
    • Resets error counters upon successful poll response and aborts immediately on non-retryable errors.
  5. Unit Tests:
    • Comprehensive test suite covering retry limits, exponential backoff with jitter, non-retryable errors, pre-aborted requests, and mid-delay cancellation.

Verification

  • make test-web: All 1,048 tests passed (TOTAL: 1048 SUCCESS).
  • make lint-web: 0 issues.
  • make build-storybook: Succeeded.
  • make build-web: Succeeded.
  • make pre-commit: Succeeded with 0 issues.
…load/download

- Introduce createRetryInterceptor with exponential backoff and jitter for idempotent unary RPCs
- Support automatic retry on transient errors (HTTP 502/503/504, connection failures)
- Enhance chunked-uploader with per-chunk retry up to 10 attempts
- Add chunk download retry up to 10 attempts in backend-api.service
- Enhance legacy polling interceptor with consecutive transient error tolerance
- Provide comprehensive unit tests covering retry logic, non-retryable errors, and cancellation
@kyasbal kyasbal added type:feature New feature or request area:frontend Web frontend application and UI components labels Aug 28, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a robust retry mechanism with exponential backoff and jitter for transient errors (such as 502, 503, 504, and network drops) across the frontend API layer, including chunked uploads/downloads, legacy polling, and idempotent unary RPCs via a new Connect-RPC interceptor. The feedback recommends throwing a custom CancellationError instead of propagating transient errors when a request is aborted, importing CancellationError via an absolute path, and correctly capping the backoff delay at maxDelayMs when jitter is applied.

Comment thread web/src/app/services/api/retry-util.ts Resolved
@kyasbal
kyasbal merged commit 92bef23 into GoogleCloudPlatform:main Aug 28, 2026
16 checks passed
@kyasbal
kyasbal deleted the push-oztswsumowus branch August 28, 2026 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:frontend Web frontend application and UI components type:feature New feature or request

1 participant