diff --git a/spec/operators/audit-spec.ts b/spec/operators/audit-spec.ts index 7f4480d7f5..1b8654ea8d 100644 --- a/spec/operators/audit-spec.ts +++ b/spec/operators/audit-spec.ts @@ -163,6 +163,18 @@ describe('Observable.prototype.audit', () => { expectSubscriptions(e2.subscriptions).toBe(e2subs); }); + it('should mirror source if durations are synchronous observables', () => { + const e1 = hot('abcdefabcdefabcdefabcdefa|'); + const e1subs = '^ !'; + const e2 = Rx.Observable.of('one single value'); + const expected = 'abcdefabcdefabcdefabcdefa|'; + + const result = e1.audit(() => e2); + + expectObservable(result).toBe(expected); + expectSubscriptions(e1.subscriptions).toBe(e1subs); + }); + it('should raise error as soon as just-throw duration is used', () => { const e1 = hot('----abcdefabcdefabcdefabcdefa|'); const e1subs = '^ ! '; diff --git a/src/internal/operators/audit.ts b/src/internal/operators/audit.ts index 5c5381a9ca..126d681dbe 100644 --- a/src/internal/operators/audit.ts +++ b/src/internal/operators/audit.ts @@ -89,7 +89,7 @@ class AuditSubscriber extends OuterSubscriber { this.destination.error(errorObject.e); } else { const innerSubscription = subscribeToResult(this, duration); - if (innerSubscription.closed) { + if (!innerSubscription || innerSubscription.closed) { this.clearThrottle(); } else { this.add(this.throttled = innerSubscription);