Skip to content

Commit

Permalink
fix unsubscribe from optimistic inflight subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
FZambia committed Apr 1, 2024
1 parent 04e4f7b commit dbf1a73
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/centrifuge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1379,9 +1379,16 @@ export class Centrifuge extends (EventEmitter as new () => TypedEventEmitter<Cli
}

protected _unsubscribe(sub: Subscription) {
if (!this._isConnected()) {
// Optimistic subscription could be sent together with connect command in one frame, so
// Centrifuge can be in the connecting state – but we still need to send unsubscribe frame
// to the server.
// @ts-ignore – we are hiding some symbols from public API autocompletion.
const isSubOptimisticallySent = this._isConnecting() && sub._inflight;

if (!this._isConnected() && !isSubOptimisticallySent) {
return;
}

const req = {
channel: sub.channel
};
Expand Down

0 comments on commit dbf1a73

Please sign in to comment.