Improve error handling and add fetch retry backoff #534
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.
Types of changes
Description
This PR introduces a few improvements to error handling and security validation.
Changes Made
I added URL validation with try-catch to handle malformed Supabase URLs for better DX. I added exponential backoff delays (100-300ms) between fetch retry attempts in the fetch-retry.ts utils so we have a little delay for each retry. I added a database types warning message instead of returning silently "unknown" for better DX. I extracted matchesAnyPattern helper in auth redirect to reduce code duplication (the regex check). I added the fetchWithRetry to server/service/serverSupabaseServiceRole.ts for consistency.
I am open for any changes or rollbacks on single changes, for example the types warning message or if we should set a fallback prefix, if the supabase url does not pass the check or if the fetchWithRetry was intentionally not added to the serverSupabaseServiceRole.
Checklist: