Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(retryWhen): Ensure subscription tears down between retries #5623

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
chore: respond to feedback
  • Loading branch information
benlesh committed Aug 5, 2020
commit a24b88d76e1b1942acc9db5e53cc37d832e441d2
8 changes: 4 additions & 4 deletions src/internal/operators/retryWhen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function retryWhen<T>(notifier: (errors: Observable<any>) => Observable<a
notifier$.subscribe({
next: () => {
if (innerSub) {
subscribeNext();
subscribeForRetryWhen();
} else {
// If we don't have an innerSub yet, that's because the inner subscription
// call hasn't even returned yet. We've arrived here synchronously.
Expand All @@ -107,7 +107,7 @@ export function retryWhen<T>(notifier: (errors: Observable<any>) => Observable<a
return errors$;
};

const subscribeNext = () => {
const subscribeForRetryWhen = () => {
innerSub = source.subscribe({
next: (value) => subscriber.next(value),
error: (err) => {
Expand All @@ -129,14 +129,14 @@ export function retryWhen<T>(notifier: (errors: Observable<any>) => Observable<a
// We may need to do this multiple times, so reset the flag.
syncResub = false;
// Resubscribe
subscribeNext();
subscribeForRetryWhen();
} else {
subscription.add(innerSub);
}
};

// Start the subscription
subscribeNext();
subscribeForRetryWhen();

return subscription;
});
Expand Down