Skip to content

Commit 325c2c9

Browse files
authored
fix: Bind proper object to setAuth on Realtime callback (#1324)
1 parent 0ea6d8f commit 325c2c9

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"@supabase/functions-js": "2.4.3",
4545
"@supabase/node-fetch": "2.6.15",
4646
"@supabase/postgrest-js": "1.16.3",
47-
"@supabase/realtime-js": "2.10.9",
47+
"@supabase/realtime-js": "2.11.2",
4848
"@supabase/storage-js": "2.7.1"
4949
},
5050
"devDependencies": {

src/SupabaseClient.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,11 @@ export default class SupabaseClient<
117117
}
118118

119119
this.fetch = fetchWithAuth(supabaseKey, this._getAccessToken.bind(this), settings.global.fetch)
120-
121-
this.realtime = this._initRealtimeClient({ headers: this.headers, ...settings.realtime })
120+
this.realtime = this._initRealtimeClient({
121+
headers: this.headers,
122+
accessToken: this._getAccessToken.bind(this),
123+
...settings.realtime,
124+
})
122125
this.rest = new PostgrestClient(`${_supabaseUrl}/rest/v1`, {
123126
headers: this.headers,
124127
schema: settings.db.schema,
@@ -330,13 +333,9 @@ export default class SupabaseClient<
330333
(event === 'TOKEN_REFRESHED' || event === 'SIGNED_IN') &&
331334
this.changedAccessToken !== token
332335
) {
333-
// Token has changed
334-
this.realtime.setAuth(token ?? null)
335-
336336
this.changedAccessToken = token
337337
} else if (event === 'SIGNED_OUT') {
338-
// Token is removed
339-
this.realtime.setAuth(this.supabaseKey)
338+
this.realtime.setAuth()
340339
if (source == 'STORAGE') this.auth.signOut()
341340
this.changedAccessToken = undefined
342341
}

0 commit comments

Comments
 (0)