fix(auth): do not console.error AuthApiError already returned through contract#2428
Merged
mandarini merged 1 commit intoJun 4, 2026
Conversation
@supabase/auth-js
@supabase/functions-js
@supabase/postgrest-js
@supabase/realtime-js
@supabase/storage-js
@supabase/supabase-js
commit: |
mandarini
approved these changes
Jun 4, 2026
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.
Description
In SSR/Edge environments (Next.js middleware on Vercel Edge Runtime), every
supabase.auth.getUser()call against a session with a stale refresh token produces a noisy[AuthApiError]: Invalid Refresh Tokenline in server logs.What changed?
In
_recoverAndRefreshinsideGoTrueClient.ts, theelsebranch after the discarded-error guard was callingconsole.error(error)unconditionally. This error is already returned through the public API contract via_callRefreshToken's return value — the caller receives{ data: null, error }correctly. The bareconsole.erroradds no diagnostic value and duplicates the error surface.The fix replaces
console.error(error)withthis._debug(debugName, 'refresh failed', error), matching the pattern of theisAuthRefreshDiscardedErrorbranch immediately above it.Closes #2416
Type of Change
Testing
GoTrueClient.test.tsassertsconsole.erroris not called when_recoverAndRefreshencounters a stale refresh tokenChecklist
pnpm nx format)pnpm nx test:auth auth-js)pnpm nx affected --target=build)pnpm commit)