-
-
Notifications
You must be signed in to change notification settings - Fork 346
Fix: Realtime setup with GoTrue v2 #468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
this.fetch = fetchWithAuth(supabaseKey, this._getAccessToken.bind(this), settings.fetch) | ||
|
||
this.auth = this._initSupabaseAuthClient(settings.auth || {}, this.headers, this.fetch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@soedirgo fyi this was a circular reference. Is there any reason why we can't use the regular settings.fetch
here instead of our fetchWithAuth
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like the circular reference is this.auth
-> this.fetch
-> this._getAccessToken
-> this.auth
not quite familiar with gotrue-js but I can't think of any reason not to use settings.fetch
off the top of my head (but we def can't use it for functions
and storage
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. It's only if we were doing something extra in fetchWithAuth
that gotrue-js
needed... but yeah it just does a normal fetch so thanks, Bobbie!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alaister realtime changes lgtm!
Co-authored-by: Wen Bo Xie <[email protected]>
@alaister good point! will add to backlog. |
What kind of change does this PR introduce?
Fix
What is the current behaviour?
The current setup may not set an access token until the token is refreshed. This is because of a race condition where if the initial
SIGNED_IN
event occurs while the channel is in anisJoining
state, it won't send the access token.What is the new behaviour?
This setup sets the join token if we have it, and always sets the access token after the channel has joined successfully.
Additional context
It's worth mentioning in the docs that there may (rarely) be a case where realtime connects with the anon token even when the user is logged in before it sends up the current users token.