-
-
Notifications
You must be signed in to change notification settings - Fork 77
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
Each setAuth call sends a new access_token payload (all good):
realtime-js/src/RealtimeClient.ts
Lines 337 to 347 in 82e9966
setAuth(token: string | null): void { | |
this.accessToken = token | |
this.channels.forEach((channel) => { | |
token && channel.updateJoinPayload({ access_token: token }) | |
if (channel.joinedOnce && channel._isJoined()) { | |
channel._push(CHANNEL_EVENTS.access_token, { access_token: token }) | |
} | |
}) | |
} |
Each sendHeartBeat call calls setAuth (even if accessToken hasn't changeD), which results in a lot of unnecessary messages being sent:
realtime-js/src/RealtimeClient.ts
Lines 553 to 574 in 82e9966
private _sendHeartbeat() { | |
if (!this.isConnected()) { | |
return | |
} | |
if (this.pendingHeartbeatRef) { | |
this.pendingHeartbeatRef = null | |
this.log( | |
'transport', | |
'heartbeat timeout. Attempting to re-establish connection' | |
) | |
this.conn?.close(WS_CLOSE_NORMAL, 'hearbeat timeout') | |
return | |
} | |
this.pendingHeartbeatRef = this._makeRef() | |
this.push({ | |
topic: 'phoenix', | |
event: 'heartbeat', | |
payload: {}, | |
ref: this.pendingHeartbeatRef, | |
}) | |
this.setAuth(this.accessToken) | |
} |
Also, each call to join a channel triggers new call to access_token, even though the accessToken is also sent with the phx_join
event already.
Are we being charged for all these unnecessary messages being sent?
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working