Mitigate intermittent PostgREST JWT errors on first load - #46
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
No result files to import. |
Collaborator
Author
|
This can likely be removed after the Supabase fix goes live and the upgrade is done via the dashboard. |
This branch was successfully deployed
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 this changes
Production visitors reported that the first page load sometimes shows “Something went wrong / JWT issued at future,” while a subsequent reload succeeds. Retry page-data reads automatically when the configured Supabase REST endpoint returns HTTP 401 with exactly
PGRST303/JWT issued at future.Retries wait 250 ms, 750 ms, then 1500 ms and reuse the same credentials. Successful retries let the page load normally; persistent failures still reach the existing error state. Other errors, writes, and auth requests are not retried. Aborted requests do not issue another retry.
PostgREST issue and limits
This symptom matches a known PostgREST stale time-cache bug that can reject valid JWTs as issued in the future. See upstream fix #5208, released in PostgREST 14.18 and 16.3, and Supabase's incident report. Supabase's September 17 update says affected projects will need an official dashboard upgrade once its new version is available.
This is a bounded client-side mitigation, not a fix for the underlying server timing bug or a guarantee of recovery. The production PostgREST version and the exact cause of the reported failure have not been verified. Durable remediation belongs in Supabase's managed update; no custom PostgREST build is required. This PR does not refresh tokens, clear sessions, or change hosted services.
Checks
npm --prefix frontend run build(tsc -b && vite build).npm --prefix frontend run results:testpasses: 25 tests, including recovery, retry exhaustion, request scope, error preservation, cancellation, and network failures.