-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
RFC: Ability to customise resubscribeInCaseOfError functionality to allow for user interaction with errors #2294
Comments
The I think a custom RxJS operator would be more suitable if you want this customized. |
@timdeschryver yep I understand the usefulness of |
I've created a draft PR that I've verified works with my use case, I'd like feedback on the general strategy before I add tests for this use case as there's a significant amount of tests missing in the area of modules/effects/src/effects_resolver.ts
|
Would providing custom |
@alex-okrushko that was my initial thought but no actually - the existing implementation only invokes the platform/modules/effects/src/effects_resolver.ts Lines 54 to 65 in de703f0
|
Here are my thoughts on this:
|
I'm going to close this issue because we share the same thoughts here @alex-okrushko . (or if @brandonroberts thinks otherwise) |
@alex-okrushko I disagree with your second statement, which is pivotal to the point of this issue and associated PR. I understand the desire to keep the API surface minimal, however we're in a position that the only options available to us are cumbersome and error prone, or wrapping the ngrx framework in something that is usable for our needs. To me this tells me that there is room for minor customisation of behavior to support custom error handling. The latest update that introduces resubscription represents a breaking change, which can cause very unexpected failure conditions and infinite loops. What is worse is that there is no safe way to escape from this failure in a generic fashion, rather developers have to remember to explicitly handle this case every time this can happen, or as you say not use the ngrx api at all in userland code and wrap it to make it safer. Neither of these options are good, and I'm disappointed that a call to add robust error handling customisation, with an accompanying example PR is dismissed without further discussion. |
Also regarding wrapping |
It seems to be a trade-off between customisation and API surface area, as a framework user I would be far more frustrated not being able to change the behaviour rather than having to deal with the consequences of a large API. This will be the second large project using ngrx I will have had to monkey-patch to get the desired behaviour. |
@zakhenry @tyroneneill Now the |
Apologies, perhaps I was too eager to close this issue now that I've read the responses. My understanding is that #2303 adds the number of retries in the default behavior (in dev mode?) - if a error handler is provided the NgRx effect uses the custom handler (thus will not retry automatically). I think this is also what you meant, right @alex-okrushko ? |
@timdeschryver Hmm I'm not sure that this fix would directly resolve that issue, however it would at least provide the mechanism for downstream projects to implement this behavior. I suppose a strategy might be to introduce the customisation capability, then later add a more developer friendly devmode-only implementation as the default behavior? |
@alex-okrushko I agree with you on the naming not really making sense now, do you think the change should be done now (and make this a breaking change for 9.x)? Given 9.x seems to be just around the corner that might be practical |
Breaking change should be fine. Surprisingly (or maybe not so much), I haven't found even a single case where |
BREAKING CHANGE: `resubscribeOnError` renamed to `useEffectsErrorHandler` in `createEffect` metadata Closes ngrx#2294
#2295 has now been updated to incorporate the breaking change and now includes tests. |
BREAKING CHANGE: `resubscribeOnError` renamed to `useEffectsErrorHandler` in `createEffect` metadata Closes ngrx#2294
BREAKING CHANGE: `resubscribeOnError` renamed to `useEffectsErrorHandler` in `createEffect` metadata Closes ngrx#2294
BREAKING CHANGE: `resubscribeOnError` renamed to `useEffectsErrorHandler` in `createEffect` metadata Closes ngrx#2294
BREAKING CHANGE: `resubscribeOnError` renamed to `useEffectsErrorHandler` in `createEffect` metadata Closes ngrx#2294
BREAKING CHANGE: `resubscribeOnError` renamed to `useEffectsErrorHandler` in `createEffect` metadata Closes ngrx#2294
BREAKING CHANGE: `resubscribeOnError` renamed to `useEffectsErrorHandler` in `createEffect` metadata Closes ngrx#2294
BREAKING CHANGE: `resubscribeOnError` renamed to `useEffectsErrorHandler` in `createEffect` metadata Closes ngrx#2294
BREAKING CHANGE: `resubscribeOnError` renamed to `useEffectsErrorHandler` in `createEffect` metadata Closes ngrx#2294
Closes #2294 BREAKING CHANGE: `resubscribeOnError` renamed to `useEffectsErrorHandler` in `createEffect` metadata BEFORE: ```ts class MyEffects { effect$ = createEffect(() => stream$, { resubscribeOnError: true, // default }); } ``` AFTER: ```ts class MyEffects { effect$ = createEffect(() => stream$, { useEffectsErrorHandler: true, // default }); } ```
Currently the
resubscribeInCaseOfError
function is not configurable, and it simply callserrorHandler.handleError(error)
and resubscribes. This behavior is not sufficient in the case that the application has a custom error handler that allows users to decide whether or not to retry the failure.The cleanest solution would likely be to
provide
theresubscribeInCaseOfError
function using an injected symbol, which would allow downstream consumers to do something along the lines of the following:Describe any alternatives/workarounds you're currently using
Using a custom rxjs operator for every effect
Other information:
If accepted, I would be willing to submit a PR for this feature
[x] Yes (Assistance is provided if you need help submitting a pull request)
[ ] No
The text was updated successfully, but these errors were encountered: