Skip to content

Commit

Permalink
feat: no persist of session with no changes in _recoverAndRefresh (#…
Browse files Browse the repository at this point in the history
…711)

In `_recoverAndRefresh()` if the session was valid and not expired by
the margin, it was loading and then persisting which could have
overridden a new session value saved by another tab in local storage.

This explains some errors where a refresh token is used again after a
long time.

---------

Co-authored-by: Joel Lee <[email protected]>
  • Loading branch information
hf and J0 authored Jun 27, 2023
1 parent 65f1c52 commit 964f2fd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/GoTrueClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1283,9 +1283,9 @@ export default class GoTrueClient {
}
}
} else {
if (this.persistSession) {
await this._saveSession(currentSession)
}
// no need to persist currentSession again, as we just loaded it from
// local storage; persisting it again may overwrite a value saved by
// another client with access to the same local storage
await this._notifyAllSubscribers('SIGNED_IN', currentSession)
}
} catch (err) {
Expand Down

0 comments on commit 964f2fd

Please sign in to comment.