Skip to content

Commit 3b8cf94

Browse files
committed
fix(expand): terminate recursive call when destination completes
relates to #766
1 parent 01f86e5 commit 3b8cf94

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/operators/expand-support.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,19 @@ export class ExpandSubscriber<T, R> extends OuterSubscriber<T, R> {
3333
}
3434

3535
_next(value: any): void {
36+
const destination = this.destination;
37+
38+
if (destination.isUnsubscribed) {
39+
this._complete();
40+
return;
41+
}
42+
3643
const index = this.index++;
3744
if (this.active < this.concurrent) {
38-
this.destination.next(value);
45+
destination.next(value);
3946
let result = tryCatch(this.project)(value, index);
4047
if (result === errorObject) {
41-
this.destination.error(result.e);
48+
destination.error(result.e);
4249
} else {
4350
if (result._isScalar) {
4451
this._next(result.value);

0 commit comments

Comments
 (0)