Skip to content

Subscription to Observable is not removed from observers array after unsubscribe() #4230

@ababashka

Description

@ababashka

Bug Report

Current Behavior
Currently subscription isn't removed from observers array after unsubscribe, both with takeUntil() and unsubscribe().

Reproduction

function called() { console.log('CALLED'); }

const subject = new Subject();
const destroyed = new Subject();

const subscription = subject
        .pipe(takeUntil(destroyed))
        .subscribe(() => called());

console.log(subject.observers.length); // 1

subject.next(); // CALLED
subject.next(); // CALLED

// Unsubscribe from subject
destroyed.next(true);
destroyed.complete();

console.log(subject.observers.length); // Still 1, expected: 0

subscription.unsubscribe();
subject.next(); // no console.log('CALLED')

console.log(subject.observers.length); // Still 1, expected: 0

Expected behavior
In 2 last console.log(subject.observers.length) it's expected to have 0 : observer should be removed from array of observers after unsubscribe()

Environment

  • RxJS version:
  • 6.3.3

Additional notes
It isn't reproducible with rxjs version 6.2.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions