Skip to content

fix(supabase_flutter): log instead of swallow auth state stream errors#1346

Merged
grdsdev merged 5 commits intomainfrom
grdsdev/log-auth-state-errors
Apr 7, 2026
Merged

fix(supabase_flutter): log instead of swallow auth state stream errors#1346
grdsdev merged 5 commits intomainfrom
grdsdev/log-auth-state-errors

Conversation

@grdsdev
Copy link
Copy Markdown
Contributor

@grdsdev grdsdev commented Apr 2, 2026

Summary

  • Auth state stream errors (token refresh failures, network errors, etc.) were silently dropped in the empty onError handler inside SupabaseAuth.initialize()
  • They are now logged at warning level with full error and stack trace via the existing _log logger (supabase.supabase_flutter)
  • Updated initialize() dartdoc to document this behavior

Root Cause

packages/supabase_flutter/lib/src/supabase_auth.dart:51 had an empty onError callback:

onError: (error, stackTrace) {},  // silently dropped all errors

Changes

  • supabase_auth.dart: onError now calls _log.warning(...) instead of ignoring the error
  • auth_test.dart: Added test that calls notifyException to emit an error on the stream and asserts it appears as a WARNING log record

Test Plan

  • New test: Authentication > Auth state stream error handling > logs auth state stream errors at warning level
  • All existing tests pass (41/41)

Acceptance Criteria

  • Auth state stream errors are logged at warning level with stack trace
  • No regression in existing auth tests
  • Behavior documented in initialize() dartdoc

Closes: SDK-811


🤖 Generated with Claude Code

grdsdev and others added 3 commits April 2, 2026 15:04
Auth state stream errors (e.g. token refresh failures, network errors)
were silently dropped in the onError handler. They are now logged at
warning level with the full stack trace so developers can observe them.

Also updated the initialize() dartdoc to document this behavior.

Linear: SDK-811

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove unused gotrue import and put notifyException call on a single
line so the ignore comment suppresses the internal_member lint correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ignore comment

dart format splits long chains onto multiple lines, which moves the
notifyException call off the line covered by the ignore comment.
Extracting the auth client into a local variable keeps the ignore
comment and the internal call on adjacent lines.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@grdsdev grdsdev requested review from a team and Vinzent03 April 2, 2026 18:28
Comment thread packages/supabase_flutter/lib/src/supabase_auth.dart Outdated
GoTrueClient.notifyException already logs errors before adding them to
the stream. Remove the duplicate log and replace with a comment
explaining why the handler exists (to prevent unhandled zone errors).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@grdsdev grdsdev requested a review from Vinzent03 April 7, 2026 18:27
Apply dart format (tall style, Dart >=3.7) to auth_test.dart so the
CI formatter check passes on Flutter stable (3.x).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@grdsdev grdsdev merged commit 77ca5db into main Apr 7, 2026
9 checks passed
@grdsdev grdsdev deleted the grdsdev/log-auth-state-errors branch April 7, 2026 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants