feat: Add instrumentation and debug app for token refresh issue #1158#1257
Draft
feat: Add instrumentation and debug app for token refresh issue #1158#1257
Conversation
Pull Request Test Coverage Report for Build 18784222894Details
💛 - Coveralls |
Contributor
|
This pull request has been inactive for 90 days. If you plan to continue working on this PR, please leave a comment to keep it open. |
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.
🔍 Overview
This is a DRAFT PR for visibility and collaboration purposes. It is not intended to be merged as-is.
This PR adds comprehensive instrumentation and a dedicated debug application to help diagnose and reproduce the intermittent token refresh issue reported in #1158.
🐛 Problem Being Investigated
Users are experiencing inconsistent token refresh behavior where:
signedOutevent instead of refreshing expired tokensSee full issue details at #1158
🎯 Purpose of This PR
1. Comprehensive Instrumentation
Added detailed logging throughout the authentication flow to track:
Modified Files:
packages/gotrue/lib/src/gotrue_client.dart- Auto-refresh lifecycle, token refresh operations, session recoverypackages/supabase_flutter/lib/src/supabase_auth.dart- App lifecycle events, initialization, session recoverypackages/gotrue/lib/src/types/session.dart- Session expiry calculationspackages/supabase_flutter/lib/src/local_storage.dart- Storage operations (read/write/remove)packages/supabase_flutter/lib/src/supabase.dart- Initialization flowThe instrumentation uses hierarchical log levels:
FINEST- Very detailed timing and state informationFINE- Debug information about internal operationsINFO- Important state changes and eventsWARNING- Errors and unexpected conditions2. Token Refresh Debug App
Created a complete Flutter application at
examples/token_refresh_debug_app/that provides:Features:
See the comprehensive README:
examples/token_refresh_debug_app/README.md🧪 How to Use the Debug App
Quick Start
Navigate to the debug app:
cd examples/token_refresh_debug_app melos bootstrap flutter runConfigure your Supabase project with a short token expiry (e.g., 5 minutes) for easier testing
Launch the app and enter your Supabase URL and anon key
Sign in with a test user
Try reproducing the issue using one of these scenarios:
Monitor the logs for:
Expected vs Problematic Behavior
✅ Expected (successful refresh):
❌ Problematic (bug reproduced):
🤝 How You Can Help
We're inviting the community to help us:
Reproduce the issue using the debug app
Share logs showing the exact sequence of events
Report your findings including:
Test proposed fixes once we identify root causes
📊 What We've Learned So Far
From analyzing the code and issue reports, we've identified potential root causes:
The instrumentation will help us confirm which of these (or other factors) are causing the issue.
🔗 Related Issues
Closes #1158 (when actual fixes are implemented)
📝 Testing Checklist
If you're helping test, please try to:
💬 Discussion
Please share your findings, logs, and observations in the issue #1158 or comment on this PR.
Note: This PR will remain in draft status while we gather data and develop proper fixes. Once we have confirmed fixes, we'll create a separate PR for the actual implementation.