Skip to content

Eech heartbeat and channel join sends a new accessToken, even if token hasn't changed, same for channel join #434

Open
@lauri865

Description

@lauri865

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):

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:

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

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions