rxjs icon indicating copy to clipboard operation
rxjs copied to clipboard

Unsubscribing from WebSocketSubject reference to Websocket

Open webstp opened this issue 10 years ago • 2 comments

[email protected]

When unsubscribing from a multiplex WebSocketSubject I am seeing the socket getting set to null. There are still other subscribers and the socket still exists, but we are loosing the reference to the socket

I believe this was introduced in 62d242e.

Relevant Code

protected _subscribe(subscriber: Subscriber<T>): Subscription {
    const { source } = this;
    if (source) {
      return source.subscribe(subscriber);
    }
    if (!this.socket) {
      this._connectSocket();
    }
    let subscription = new Subscription();
    subscription.add(this._output.subscribe(subscriber));
    subscription.add(() => {
      const { socket } = this;
      if (this._output.observers.length === 0 && socket && socket.readyState === 1) {
        socket.close();
      }
      this._resetState(); //This is where to socket reference is getting lost
    });
    return subscription;
  }

webstp avatar Oct 14 '16 18:10 webstp

Oops, yup, I see the bug there. Thanks @webstp

benlesh avatar Oct 14 '16 23:10 benlesh

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Jun 06 '18 23:06 lock[bot]