Skip to content

Commit ece8663

Browse files
authored
feat: make apikey mandatory; improve stability and readability of code (#502)
1 parent d3026be commit ece8663

File tree

7 files changed

+1401
-157
lines changed

7 files changed

+1401
-157
lines changed

src/RealtimeChannel.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,15 @@ export default class RealtimeChannel {
198198
this.state = CHANNEL_STATES.errored
199199
this.rejoinTimer.scheduleTimeout()
200200
})
201+
202+
this.joinPush.receive('error', (reason: any) => {
203+
if (this._isLeaving() || this._isClosed()) {
204+
return
205+
}
206+
this.socket.log('channel', `error ${this.topic}`, reason)
207+
this.state = CHANNEL_STATES.errored
208+
this.rejoinTimer.scheduleTimeout()
209+
})
201210
this._on(CHANNEL_EVENTS.reply, {}, (payload: any, ref: string) => {
202211
this._trigger(this._replyEventName(ref), payload)
203212
})
@@ -225,7 +234,9 @@ export default class RealtimeChannel {
225234
const postgres_changes =
226235
this.bindings.postgres_changes?.map((r) => r.filter) ?? []
227236

228-
const presence_enabled = !!this.bindings[REALTIME_LISTEN_TYPES.PRESENCE]
237+
const presence_enabled =
238+
!!this.bindings[REALTIME_LISTEN_TYPES.PRESENCE] &&
239+
this.bindings[REALTIME_LISTEN_TYPES.PRESENCE].length > 0
229240
const accessTokenPayload: { access_token?: string } = {}
230241
const config = {
231242
broadcast,

0 commit comments

Comments
 (0)