Skip to content

Commit fad2bb7

Browse files
grdsdevclaude
andauthored
docs(gotrue): document the _refreshTokenCompleter concurrent-request deduplication pattern (#1342)
Expand the comment on `_refreshTokenCompleter` to explain the race condition it prevents, how the deduplication mechanism works, and that the completer is cleared after resolution for the next cycle. Linear: SDK-813 Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7121ac2 commit fad2bb7

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

packages/gotrue/lib/src/gotrue_client.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ class GoTrueClient {
5656

5757
Timer? _autoRefreshTicker;
5858

59-
/// Completer to combine multiple simultaneous token refresh requests.
59+
/// Deduplicates concurrent token refresh requests.
60+
///
61+
/// When multiple callers detect an expired token simultaneously (e.g. several
62+
/// in-flight API requests all fail with 401), only the first creates a new
63+
/// refresh network request. Subsequent callers receive the same [Future] and
64+
/// wait for the single in-flight request to complete. The completer is cleared
65+
/// after resolution so the next expiry cycle starts a fresh request.
6066
Completer<AuthResponse>? _refreshTokenCompleter;
6167

6268
JWKSet? _jwks;

0 commit comments

Comments
 (0)