-
由 Will Chen 提交于
Addresses #2147 <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds robust retry handling for Supabase API interactions to reduce flakiness on HTTP 429. > > - Introduces `RateLimitError`, `isRateLimitError`, `retryWithRateLimit` (defaults: 6 retries, 2s base, capped, jitter, scoped logging) and `fetchWithRetry` > - Applies retries to key callsites: project API keys, schema/queries, secrets, orgs/members/details, projects, project logs, branches, function deploy/delete, bulk update, and SQL execution > - Standardizes non-429 fetch failures to throw `SupabaseManagementAPIError` to preserve response context > - Improves function deploy by rebuilding `FormData` per attempt and converting 429 to `RateLimitError` > - Adds thorough unit tests covering error detection, backoff behavior, options, and retry exhaustion > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit eaf86cffb2d2b3a3771e8607a52f4e04af630ecd. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Add automatic retries for Supabase API calls on HTTP 429 using exponential backoff with jitter to reduce flakiness and improve reliability. Addresses #2147 by applying retries across key management and context callsites and adding thorough tests. - **New Features** - Added retryWithRateLimit (defaults: 8 retries, 2s base delay, 30s max, 10% jitter, scoped logging), isRateLimitError, RateLimitError, and fetchWithRetry. - Applied retries to fetch-based endpoints and runQuery operations: orgs/members/details/projects, project logs, schema/table/function queries, secrets/API keys, branches, function deploy/delete and bulk update, and SQL execution. - Standardized error handling by throwing SupabaseManagementAPIError for failed fetches to preserve response details. - Added unit tests covering detection, backoff timing, options, retry exhaustion, and fetchWithRetry behavior. <sup>Written for commit c1fbffaf9c559c7f43a6999f4160a81b97ed9eaf. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. -->