Skip to content

Commit e797bd7

Browse files
authored
fix(retry): when # of retries is smaller than one (#6359)
1 parent c5dbfd6 commit e797bd7

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

spec/operators/retry-spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,4 +326,17 @@ describe('retry operator', () => {
326326

327327
expect(sideEffects).to.deep.equal([0, 1, 2]);
328328
});
329+
330+
it('should not alter the source when the number of retries is smaller than 1', () => {
331+
const source = cold('--1-2-3-#');
332+
const subs = ['^ !'];
333+
334+
const expected = '--1-2-3-#';
335+
const unsub = ' !';
336+
337+
const result = source.pipe(retry(0));
338+
339+
expectObservable(result, unsub).toBe(expected);
340+
expectSubscriptions(source.subscriptions).toBe(subs);
341+
})
329342
});

src/internal/operators/retry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { MonoTypeOperatorFunction } from '../types';
22
import { operate } from '../util/lift';
33
import { Subscription } from '../Subscription';
4-
import { EMPTY } from '../observable/empty';
54
import { OperatorSubscriber } from './OperatorSubscriber';
5+
import { identity } from '../util/identity';
66

77
export interface RetryConfig {
88
count: number;
@@ -69,7 +69,7 @@ export function retry<T>(configOrCount: number | RetryConfig = Infinity): MonoTy
6969
const { count, resetOnSuccess = false } = config;
7070

7171
return count <= 0
72-
? () => EMPTY
72+
? identity
7373
: operate((source, subscriber) => {
7474
let soFar = 0;
7575
let innerSub: Subscription | null;

0 commit comments

Comments
 (0)