docs(gotrue): require onError handler in onAuthStateChange#1355
Merged
Conversation
Network errors (e.g. offline token refresh) are emitted as stream errors on onAuthStateChange. Without an onError handler, Dart rethrows them as unhandled zone exceptions and crashes the app. - Update onAuthStateChange doc comment in GoTrueClient with a clear warning and a corrected usage example that includes onError - Fix the supabase_flutter example app which was missing onError and would crash when the device had no connectivity Fixes #1281 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Vinzent03
approved these changes
Apr 16, 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.
Summary
onAuthStateChangedoc comment inGoTrueClientwith an explicit warning thatonErroris required, plus a corrected usage exampleonErrorand would crash when the device had no connectivityBackground
Closes #1281.
Network errors (e.g. a token refresh while offline) are emitted as stream errors on
onAuthStateChange. Without anonErrorhandler, Dart rethrows them as unhandled zone exceptions, crashing the app. The SDK's own internal listener insupabase_auth.dartalready handles this correctly — the gap was in documentation and the example app.A companion PR in the reference docs repo updates all code examples on supabase.com: supabase/supabase#44946
Changes
packages/gotrue/lib/src/gotrue_client.dartonAuthStateChangedoc comment to warn thatonErroris requiredonErrorpackages/supabase_flutter/example/lib/main.dartonErrorhandler to the.listen()call that was missing itTest plan
🤖 Generated with Claude Code