Skip to content

Commit 76b7e27

Browse files
authored
fix(audit): will not crash if duration is synchronous (#3608)
closes #2743
1 parent b948e65 commit 76b7e27

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Diff for: spec/operators/audit-spec.ts

+12
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,18 @@ describe('Observable.prototype.audit', () => {
163163
expectSubscriptions(e2.subscriptions).toBe(e2subs);
164164
});
165165

166+
it('should mirror source if durations are synchronous observables', () => {
167+
const e1 = hot('abcdefabcdefabcdefabcdefa|');
168+
const e1subs = '^ !';
169+
const e2 = Rx.Observable.of('one single value');
170+
const expected = 'abcdefabcdefabcdefabcdefa|';
171+
172+
const result = e1.audit(() => e2);
173+
174+
expectObservable(result).toBe(expected);
175+
expectSubscriptions(e1.subscriptions).toBe(e1subs);
176+
});
177+
166178
it('should raise error as soon as just-throw duration is used', () => {
167179
const e1 = hot('----abcdefabcdefabcdefabcdefa|');
168180
const e1subs = '^ ! ';

Diff for: src/internal/operators/audit.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class AuditSubscriber<T, R> extends OuterSubscriber<T, R> {
8989
this.destination.error(errorObject.e);
9090
} else {
9191
const innerSubscription = subscribeToResult(this, duration);
92-
if (innerSubscription.closed) {
92+
if (!innerSubscription || innerSubscription.closed) {
9393
this.clearThrottle();
9494
} else {
9595
this.add(this.throttled = innerSubscription);

0 commit comments

Comments
 (0)