Skip to content

Commit

Permalink
fix: don't compare agent channel param when determining whether cha…
Browse files Browse the repository at this point in the history
…nnel options require reattach
  • Loading branch information
Owen Pearson authored and Owen Pearson committed Nov 1, 2023
1 parent e3e6781 commit 5b8fdb3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/common/lib/client/realtimechannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,14 @@ class RealtimeChannel extends Channel {
return false;
}
if (options?.params) {
if (!this.params || !Utils.shallowEquals(this.params, options.params)) {
// Don't check against the `agent` param - it isn't returned in the ATTACHED message
const requestedParams = Object.assign({}, options.params);
delete requestedParams.agent;
if (Object.keys(requestedParams).length !== 0 && !this.params) {
return true;
}

if (this.params && !Utils.shallowEquals(this.params, requestedParams)) {
return true;
}
}
Expand Down Expand Up @@ -630,6 +637,7 @@ class RealtimeChannel extends Channel {
case actions.ATTACHED: {
this.properties.attachSerial = message.channelSerial;
this._mode = message.getMode();
console.log('Channel.onMessage ATTACHED, setting params to:', (message as any).params);
this.params = (message as any).params || {};
const modesFromFlags = message.decodeModesFromFlags();
this.modes = (modesFromFlags && Utils.allToLowerCase(modesFromFlags)) || undefined;
Expand Down

0 comments on commit 5b8fdb3

Please sign in to comment.