Suppress self-recovering "JWT expired" errors from background Supabase client#39
Merged
Merged
Conversation
…e client Add a "JWT expired" / PGRST301 guard to captureSupabaseError's non-actionable filter set, alongside the existing PGRST116 and Unauthorized suppressions. When ensureSessionReady() can't refresh an expired access token (revoked refresh_token, network), it deliberately lets the request run anyway, so PostgREST rejects it with "JWT expired". That's a self-recovering auth-transition state — the next request re-auths via the QR flow — not an actionable bug, so reporting it just adds noise and burns PostHog free-tier quota. Also have handleRpc call ensureSessionReady() like handleQuery and handleMutate do, so RPCs get the same proactive token refresh (they were the most exposed path, skipping the refresh entirely). Generated-By: PostHog Code Task-Id: 62ef8cc7-7657-4fb8-8eb0-bbac2e833512
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
jonbng
marked this pull request as ready for review
July 12, 2026 10:04
There was a problem hiding this comment.
Pull request overview
This PR reduces background Supabase error-noise in PostHog by filtering out self-recovering “JWT expired” (PGRST301) errors in captureSupabaseError, and aligns the RPC path with query/mutate by proactively calling ensureSessionReady() before executing RPCs.
Changes:
- Add
isExpiredJwtError()and suppress matching errors incaptureSupabaseError. - Call
ensureSessionReady()inhandleRpc()to refresh access tokens before RPC calls.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| try { | ||
| if (isTransientNetworkError(error)) return; | ||
| if (isNonActionablePostgrestError(error)) return; | ||
| if (isExpiredJwtError(error)) return; |
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.
Adds a "JWT expired" /
PGRST301check to the non-actionable error filter incaptureSupabaseError, mirroring the existingPGRST116andUnauthorizedsuppressions.When
ensureSessionReady()fails to refresh an expired access token (revokedrefresh_token, network), its catch block deliberately lets the request run anyway. PostgREST then rejects it with "JWT expired", which flowed unfiltered into error tracking. It's a self-recovering auth-transition state — the next request re-auths via the QR flow — so it just added noise and nibbled at PostHog free-tier quota.Also has
handleRpccallensureSessionReady()likehandleQuery/handleMutatedo, so RPCs get the same proactive token refresh (previously they skipped it entirely, making them the most exposed path).Why
A one-off "JWT expired" background-worker error was leaking into error tracking as noise (1 occurrence, 1 user, 0 sessions) with no filter to catch it.
Created with PostHog Code from an inbox report.