Skip to content

[PB-5908]: add global retry with rate-limit notifications for SDK clients#1866

Open
terrerox wants to merge 10 commits intomasterfrom
feature/global-retry
Open

[PB-5908]: add global retry with rate-limit notifications for SDK clients#1866
terrerox wants to merge 10 commits intomasterfrom
feature/global-retry

Conversation

@terrerox
Copy link
Contributor

Description

Upgrade @internxt/sdk to 1.15.0 and introduce retry strategies for HTTP requests. Silent retries (2 attempts) are enabled globally, while Storage and Share clients use a user-facing notification strategy (5 attempts) with a cooldown-based warning toast. Adds hasElapsed utility to date.service and i18n translations for the rate-limit toast in all supported languages

Related Issues

Related Pull Requests

Checklist

  • Changes have been tested locally.
  • Unit tests have been written or updated as necessary.
  • The code adheres to the repository's coding standards.
  • Relevant documentation has been added or updated.
  • No new warnings or errors have been introduced.
  • SonarCloud issues have been reviewed and addressed.
  • QA Passed

Testing Process

Additional Notes

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 24, 2026

Deploying drive-web with  Cloudflare Pages  Cloudflare Pages

Latest commit: 50d9d22
Status: ✅  Deploy successful!
Preview URL: https://49361b8f.drive-web.pages.dev
Branch Preview URL: https://feature-global-retry.drive-web.pages.dev

View logs

- uses: actions/setup-node@v4
with:
node-version: '20.11.1'
node-version: '20.19.0'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bumped from 20.11.1 to 20.19.0 to fix failing Playwright CI job.
@noble/hashes@2.0.1 (transitive dep of @internxt/sdk@1.15.0) requires Node >= 20.19.0,
which caused yarn install to fail with "Found incompatible module".

@terrerox terrerox self-assigned this Feb 25, 2026
@terrerox terrerox requested a review from CandelR February 27, 2026 03:59
@terrerox terrerox requested a review from CandelR March 3, 2026 15:35
CandelR
CandelR previously approved these changes Mar 3, 2026
terrerox added 8 commits March 9, 2026 22:04
Upgrade @internxt/sdk to 1.15.0 and introduce retry strategies for HTTP requests. Silent retries (2 attempts) are enabled globally, while Storage and Share clients use a user-facing notification strategy (5 attempts) with a cooldown-based warning toast. Adds hasElapsed utility to date.service and i18n translations for the rate-limit toast in all supported languages
…way upload conflicts

  The global HttpClient.enableGlobalRetry was applying retry to all SDK clients including the gateway Network client, which broke multi-step
  uploads (start → upload parts → finish) by retrying individual steps independently. Moving retryOptions into ApiSecurity enables retry only
   for drive API clients (Storage, Share, Users, etc.) while leaving the gateway client retry-free — uploads already have operation-level
  retry.
@terrerox terrerox force-pushed the feature/global-retry branch from 6f1179d to c0f0d74 Compare March 10, 2026 02:04
  Previously, per-client retryOptions only covered Storage/Share clients
  in the main thread, leaving gateway startUpload/finishUpload calls in
  Web Workers without 429 handling. This restores HttpClient.enableGlobalRetry
  in both the main thread and upload worker context.
@terrerox terrerox requested a review from a team as a code owner March 10, 2026 03:01
…ent gateway upload conflicts"

This reverts commit c0f0d74.
@sonarqubecloud
Copy link

import { t } from 'i18next';
import { retryStrategies, NotifyUserCallback } from './retryStrategies';

const RETRY_TOAST_DURATION_MS = 60000;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should move all constants in src/app/core/constants.ts so that they are all in one place. @CandelR do we have a file with constants specific to sdk or is the one in core the only one?

return Math.max(0, Math.ceil(diffInDays));
};

const hasElapsed = (since: Dayjs, amount: number, unit: dayjs.ManipulateType): boolean =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need a function for this? It's called in only one place and it's a one-line function

Copy link
Contributor

Choose a reason for hiding this comment

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

For me its better that way:

  • Readability: hasElapsed(since, 5, 'minute') reads closer to plain English than dayjs().diff(since, 'minute') >= 5, which requires 'knowing' the dayjs API
  • Testability: a named function is easier to unit test in isolation
  • Future reuse: "called in only one place now" doesn't mean it won't be reused later 🤔
  • Abstraction: it hides the dayjs dependency, so if you ever swap date libraries, there's one place to change

wdyt? @TamaraFinogina

@@ -0,0 +1,23 @@
import { RetryOptions } from '@internxt/sdk/dist/shared';

export const SILENT_MAX_RETRIES = 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same with those constants

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.

5 participants