fix: suppress benign supabase stale-refresh-token exceptions#19
Draft
posthog[bot] wants to merge 4 commits into
Draft
fix: suppress benign supabase stale-refresh-token exceptions#19posthog[bot] wants to merge 4 commits into
posthog[bot] wants to merge 4 commits into
Conversation
supabase-js's background auto-refresh timer throws an uncaught AuthApiError when the stored refresh token is stale (signed out elsewhere, cleared storage, or an expired session). With capture_exceptions enabled, PostHog's exception autocapture files that expected auth event as an error. Drop it in the existing before_send sanitizer: $exception events whose exception list contains an AuthApiError with an "Invalid Refresh Token" message are no longer captured. Generated-By: PostHog Code Task-Id: 46aad295-db02-4e45-8291-aaa650e8c801
❌ Deploy Preview for postshow failed. Why did it fail? →
|
Harden the stale-refresh-token suppression so it also recognizes the error when a capture path populates the flat $exception_types / $exception_values convenience arrays instead of the structured $exception_list. Scope is unchanged — still only AuthApiError with an "Invalid Refresh Token" message. Generated-By: PostHog Code Task-Id: 46aad295-db02-4e45-8291-aaa650e8c801
Generated-By: PostHog Code Task-Id: 46aad295-db02-4e45-8291-aaa650e8c801
…-noise Generated-By: PostHog Code Task-Id: 46aad295-db02-4e45-8291-aaa650e8c801
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 changed
The
before_sendsanitizer inapps/postshow/src/lib/analytics.tsnow drops$exceptionevents whose exception list contains anAuthApiErrorwith an "Invalid Refresh Token" message, before they reach PostHog. Added a unit test covering both the dropped case and that ordinary errors still pass through.Why
supabase-js is created with
autoRefreshToken: true, so it runs a background timer that rotates the session token. When a user's stored refresh token is stale (signed out in another tab, cleared storage, or an already-expired session), that background refresh throws an uncaughtAuthApiError. Becausecapture_exceptions: trueis set, exception autocapture files this expected auth condition as an error, cluttering error tracking. Our owngetSession()path already handles auth failures gracefully; this closes the one background path we never wrapped so this class of benign event stops burying real errors.Verification
pnpm --filter @eventools/postshow test— 325 passed (includes the new suppression test)pnpm type-checkpnpm lintSafety and release impact
Client-only analytics change; no credentials, tenancy, or outbound behavior affected. The suppression is narrowly scoped to
AuthApiError+ "Invalid Refresh Token", so real errors continue to be captured.Created with PostHog Code from this inbox report.