File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed
packages/supabase/lib/src Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -14,13 +14,15 @@ class AuthHttpClient extends BaseClient {
1414 try {
1515 await _auth.refreshSession ();
1616 } catch (error) {
17- // Failed to refresh the token.
18- final isExpiredWithoutMargin = DateTime .now ().isAfter (
19- DateTime .fromMillisecondsSinceEpoch (
20- _auth.currentSession! .expiresAt! * 1000 ));
21- if (isExpiredWithoutMargin) {
22- // Throw the error instead of making an API request with an expired token.
23- rethrow ;
17+ final expiresAt = _auth.currentSession? .expiresAt;
18+ if (expiresAt != null ) {
19+ // Failed to refresh the token.
20+ final isExpiredWithoutMargin = DateTime .now ()
21+ .isAfter (DateTime .fromMillisecondsSinceEpoch (expiresAt * 1000 ));
22+ if (isExpiredWithoutMargin) {
23+ // Throw the error instead of making an API request with an expired token.
24+ rethrow ;
25+ }
2426 }
2527 }
2628 }
You can’t perform that action at this time.
0 commit comments