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

feat(effects): limit retries to 10 by default #2376

Merged
merged 1 commit into from
Feb 13, 2020
Merged

feat(effects): limit retries to 10 by default #2376

merged 1 commit into from
Feb 13, 2020

Conversation

alex-okrushko
Copy link
Member

@alex-okrushko alex-okrushko commented Feb 13, 2020

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

Limit the number of retries to 10 by default

What kind of change does this PR introduce?

Removes infinite loop if the effect is producing errors on every retry

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Closes #2303

What is the new behavior?

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

@ngrxbot
Copy link
Collaborator

ngrxbot commented Feb 13, 2020

Preview docs changes for 14e7c34 at https://previews.ngrx.io/pr2376-14e7c34/

@brandonroberts
Copy link
Member

The changes LGTM. Is it correct that if you want to only change the number of retries, you still have to re-implement the default behavior plus that change?

@alex-okrushko
Copy link
Member Author

Is it correct that if you want to only change the number of retries, you still have to re-implement the default behavior plus that change?

One can provide the custom effects error handler like this:

@NgModule({
  imports: [EffectsModule.forRoot([MovieEffects])],
  providers: [
    {
      provide: EFFECTS_ERROR_HANDLER,
      useValue: customEffectResubscriptionHandler,
    },
    
  ],
})

// adjust the number of retries
const CUSTOM_NUMBER_OF_RETRIES = 100; 

export function customEffectResubscriptionHandler<T extends Action>(
  observable$: Observable<T>,
  errorHandler: CustomErrorHandler
): Observable<T> {
  return defaultEffectsErrorHandler(observable$, errorHandler, CUSTOM_NUMBER_OF_RETRIES);
}

Thank means that there's no need to reimplement the behavior if one wants to increase the retries number.

@brandonroberts brandonroberts merged commit 88124a7 into ngrx:master Feb 13, 2020
@timdeschryver
Copy link
Member

I find that the above snippet can be added to the docs.
If you agree, I can open up a PR for it 🙂

@alex-okrushko
Copy link
Member Author

Good idea @timdeschryver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants