fix(supabase): avoid dropping realtime auth to manual mode on client init#2464
Open
hmnd wants to merge 2 commits into
Open
fix(supabase): avoid dropping realtime auth to manual mode on client init#2464hmnd wants to merge 2 commits into
hmnd wants to merge 2 commits into
Conversation
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.
🔍 Description
When using a custom callback for
accessTokenonSupabaseClient, realtime gets stuck on the access token initially set during init, rather than refreshing from the callback as expected.What changed?
I've replaced the previous approach of manually requesting the accesstoken inside
SupabaseClient's constructor with an empty call torealtime.setAuth(). This way realtime retrieves and sets the access token on its own, without dropping to manual mode.Why was this change needed?
I ran into this issue with my custom minted jwts. I found #1304, in which the fix was to manually call
supabase.realtime.setAuth()with no args to re-enable callback mode for access tokens.I also couldn't find any documentation advising users of custom tokens that they must always call do this after client init, making for poor UX and confusing bugs.
Closes #1304
🔄 Breaking changes
Technically not a breaking change but, with this change, we do lose the
Failed to set initial Realtime auth tokenerror message if theaccessTokenfunction throws, because realtime's setAuth has its own error handling.📋 Checklist
<type>(<scope>): <description>pnpm nx formatto ensure consistent code formatting📝 Additional notes
#1304 really shouldn't have been closed and that is what frustrates me about stale bots. I would kindly suggest reconsidering the repo's usage of stale bot, or altering its config to eg. re-open issues if commented on after auto-close.