Repository navigation
refactor: drop retry dependency in favor of an in-house helper - #1571
Merged
Merged
Conversation
11 tasks
spydon
force-pushed
the
refactor/inline-retry
branch
from
July 9, 2026 12:41
8218f4b to
3b2af42
Compare
spydon
added a commit
that referenced
this pull request
Jul 9, 2026
Introduces a new published supabase_common package and moves the non-breaking shared/duplicated code into it: - ToSnakeCase enum extension (was duplicated in gotrue and storage_client) - Platform detection (was duplicated in supabase and supabase_flutter, keeping the extra isRunningInFlutterTest flag) - buildClientInfoHeader for the X-Client-Info header (simple and platform-aware forms) used by all client packages - isSuccessStatusCode 2xx helper - FetchOptions (was duplicated internally in gotrue and storage_client) - Base64Url, PKCE and uuid helpers (moved out of gotrue, also fixing an intra-gotrue duplication in jwt.dart) - A unified ReplaySubject replacing gotrue's _ReplaySubject and supabase's _BehaviorSubject - The in-house retry helper (was duplicated in gotrue and storage_client by #1571) Refs #1572
spydon
added a commit
that referenced
this pull request
Jul 9, 2026
Introduces a new published supabase_common package and moves the non-breaking shared/duplicated code into it: - ToSnakeCase enum extension (was duplicated in gotrue and storage_client) - Platform detection (was duplicated in supabase and supabase_flutter, keeping the extra isRunningInFlutterTest flag) - buildClientInfoHeader for the X-Client-Info header (simple and platform-aware forms) used by all client packages - isSuccessStatusCode 2xx helper - FetchOptions (was duplicated internally in gotrue and storage_client) - Base64Url, PKCE and uuid helpers (moved out of gotrue, also fixing an intra-gotrue duplication in jwt.dart) - A unified ReplaySubject replacing gotrue's _ReplaySubject and supabase's _BehaviorSubject - The in-house retry helper (was duplicated in gotrue and storage_client by #1571) supabase_common is excluded from the SDK compliance public-API scan via .sdk-parse-ignore: its symbols are consumed across packages and so cannot be marked @internal without tripping invalid_use_of_internal_member. Refs #1572
Tr00d
approved these changes
Jul 9, 2026
o-santi
reviewed
Jul 9, 2026
o-santi
left a comment
There was a problem hiding this comment.
Note: the helper is duplicated in each package because they are published independently and there is no shared internal utility package.
I would strongly recommend on creating a shared utility package for this use case. Even though it is the only one currently, in my experience a lot more shared code will appear, and you'll see the number of duplicated "utilities" grow over time.
|
@o-santi There's another PR specifically for this, a new |
Both gotrue and storage_client used the retry package for the same thing: exponential backoff with a retryIf predicate. gotrue used the top-level retry() and storage_client used RetryOptions. Replaces it with a small self-contained RetryOptions/retry helper in each package that mirrors the retry package's behavior (200ms delay factor, 2^attempt backoff, 25% jitter, 30s max delay, 8 max attempts by default).
spydon
force-pushed
the
refactor/inline-retry
branch
from
July 9, 2026 13:53
3b2af42 to
358f8e1
Compare
spydon
enabled auto-merge (squash)
July 9, 2026 13:53
spydon
added a commit
that referenced
this pull request
Jul 9, 2026
Introduces a new published supabase_common package and moves the non-breaking shared/duplicated code into it: - ToSnakeCase enum extension (was duplicated in gotrue and storage_client) - Platform detection (was duplicated in supabase and supabase_flutter, keeping the extra isRunningInFlutterTest flag) - buildClientInfoHeader for the X-Client-Info header (simple and platform-aware forms) used by all client packages - isSuccessStatusCode 2xx helper - FetchOptions (was duplicated internally in gotrue and storage_client) - Base64Url, PKCE and uuid helpers (moved out of gotrue, also fixing an intra-gotrue duplication in jwt.dart) - A unified ReplaySubject replacing gotrue's _ReplaySubject and supabase's _BehaviorSubject - The in-house retry helper (was duplicated in gotrue and storage_client by #1571) supabase_common is excluded from the SDK compliance public-API scan via .sdk-parse-ignore: its symbols are consumed across packages and so cannot be marked @internal without tripping invalid_use_of_internal_member. Refs #1572
spydon
added a commit
that referenced
this pull request
Jul 9, 2026
Introduces a new published supabase_common package and moves the non-breaking shared/duplicated code into it: - ToSnakeCase enum extension (was duplicated in gotrue and storage_client) - Platform detection (was duplicated in supabase and supabase_flutter, keeping the extra isRunningInFlutterTest flag) - buildClientInfoHeader for the X-Client-Info header (simple and platform-aware forms) used by all client packages - isSuccessStatusCode 2xx helper - FetchOptions (was duplicated internally in gotrue and storage_client) - Base64Url, PKCE and uuid helpers (moved out of gotrue, also fixing an intra-gotrue duplication in jwt.dart) - A unified ReplaySubject replacing gotrue's _ReplaySubject and supabase's _BehaviorSubject - The in-house retry helper (was duplicated in gotrue and storage_client by #1571) supabase_common is excluded from the SDK compliance public-API scan via .sdk-parse-ignore: its symbols are consumed across packages and so cannot be marked @internal without tripping invalid_use_of_internal_member. Refs #1572
spydon
added a commit
that referenced
this pull request
Jul 9, 2026
Introduces a new published supabase_common package and moves the non-breaking shared/duplicated code into it: - ToSnakeCase enum extension (was duplicated in gotrue and storage_client) - Platform detection (was duplicated in supabase and supabase_flutter, keeping the extra isRunningInFlutterTest flag) - buildClientInfoHeader for the X-Client-Info header (simple and platform-aware forms) used by all client packages - isSuccessStatusCode 2xx helper - FetchOptions (was duplicated internally in gotrue and storage_client) - Base64Url, PKCE and uuid helpers (moved out of gotrue, also fixing an intra-gotrue duplication in jwt.dart) - A unified ReplaySubject replacing gotrue's _ReplaySubject and supabase's _BehaviorSubject - The in-house retry helper (was duplicated in gotrue and storage_client by #1571) supabase_common is excluded from the SDK compliance public-API scan via .sdk-parse-ignore: its symbols are consumed across packages and so cannot be marked @internal without tripping invalid_use_of_internal_member. Refs #1572
spydon
added a commit
that referenced
this pull request
Jul 9, 2026
## What Introduces a new published `supabase_common` package and moves the **non-breaking** shared/duplicated code from #1572 into it. **Stacked:** `main` ← #1569 (drop rxdart) ← #1571 (drop retry, in-house helper) ← **this PR**. > [!NOTE] > Review/merge in stack order. Retarget this PR's base as each parent merges (→ `refactor/inline-retry`, then `refactor/supabase-drop-rxdart`, then `main`). ## Moved into `supabase_common` | Item | Was | |------|-----| | `ToSnakeCase` enum extension | duplicated (byte-for-byte) in `gotrue` + `storage_client` | | Platform detection (`platform_io`/`platform_stub`) | duplicated in `supabase` + `supabase_flutter` (kept the extra `isRunningInFlutterTest`) | | `buildClientInfoHeader` (`X-Client-Info`) | built in all 7 client packages (simple + platform-aware forms) | | `isSuccessStatusCode` (2xx) | inlined/duplicated in `gotrue`, `storage_client`, `postgrest`, `functions_client` | | `FetchOptions` | duplicated internally in `gotrue` + `storage_client` | | `Base64Url` / PKCE / uuid helpers | `gotrue`-only; also fixes an intra-`gotrue` duplication in `jwt.dart` | | `ReplaySubject` | unifies gotrue's `_ReplaySubject` and supabase's `_BehaviorSubject` | | `retry` / `RetryOptions` helper | the in-house copy #1571 added to `gotrue` + `storage_client` (identical); `@internal` dropped since it is now used across packages | ## Not included - **Tier 3** (shared exception base, HTTP fetch wrappers, `RetryTimer`) — breaking, tracked under v3 (#1278). ## Notes - `supabase_common` is an internal, published package (client packages cannot depend on an unpublished local package). Its README flags it as internal with breaking changes expected. - Registered in the workspace, `test.yml` (`DART_PACKAGES` + Coveralls carryforward), and `release-pana.yml`. - No public API changes: every moved symbol was either internal or re-exported so consumers importing from the client packages are unaffected. ## Verification - `dart analyze` clean across the whole workspace. - `supabase_common` unit tests pass (ToSnakeCase, client-info header, isSuccessStatusCode, Base64Url, PKCE, uuid, ReplaySubject sync/async/replay/hooks/addStream, retry). - `gotrue` (constants/helper), `functions_client` (full suite), and `supabase` (utilities) tests pass locally. Backend-dependent suites run in CI. Refs #1572
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Removes the
retrypackage from bothgotrueandstorage_client, replacing it with a small self-containedRetryOptions/retryhelper (lib/src/retry.dart) in each package.gotrueused the top-levelretry()(token refresh).storage_clientusedRetryOptions(...).retry(...)(request retries).Why
Both packages pulled in
retryfor the same narrow use: exponential backoff gated by aretryIfpredicate. The helper is ~40 lines and mirrors the package's behavior exactly:2^attemptbackoffrandomizationFactor)gotrue's time-budgetretryIfdepends on these exact defaults, so they are preserved.Testing
retry_test.dartingotruecovers success-after-retries,maxAttemptscutoff,retryIfshort-circuit,RetryOptions.retry(the storage usage shape), and exponential/capped delay math — all pass.dart analyzeclean for both packages.Note: the helper is duplicated in each package because they are published independently and there is no shared internal utility package.