-
-
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
tapResponse
swallowing errors happening inside the tapResponse
#3431
Comments
Not sure what's best here between
|
The **tap**({
next() {
throw new Error('ERROR!');
},
error(err) {
// ERROR! won't be caught here
}
}) The solution could be to move the function tapResponse(next, error, complete?) {
return pipe(
tap({ next, complete }),
catchError((err) => {
error(err);
return EMPTY;
});
);
} For now, you can use .pipe(
tap(() => {
throw new Error('ERROR!');
}),
catchError((err) => {
// handle error here
return EMPTY;
})
) |
I would find that weird. For me, or how I think about it, the What about adding a config, similar to the EffectConfig to bypass the default behavior? |
Yes 😐, it can be confusing because the behavior would be different from the
🤔 I'd not add config argument, because the implementation with
tap(() => {
throw new Error('ERROR');
}),
catchError((err) => {
// handle error
return EMPTY;
}),
tapResponse(
() => {
throw new Error('ERROR'),
},
(err) => {
// handle error
},
{ handleUnexpectedErrors: true },
) |
I don't think this would be good enough. Unless this is pretty much the first thing first first thing in the documentation, someone could miss it and the frustration to understand what's going on with a silently swallowed error can be really high. I do believe there's a need for a default behavior where you can handle this. I can't think of a case where someone would let its stream error without being warned at least |
Probably a super naive solution, still I want to share it: Try catch around the nextFn...
OK, looking at it again a few days later... I do not like it anymore. The error callback and complete callback could swallow errors as well. These callbacks would need FYI: The effect method example from here (https://ngrx.io/guide/component-store/effect#effect-method) would swallow the next fn error as well: The example could be rewritten to this:
Then api errors and next errors would be logged. |
Fixed it with try catch in MiniRx :) https://github.com/spierala/mini-rx-store/pull/117/files |
Just spent hours finding this problem. Here's the example showing the problem - https://stackblitz.com/edit/angular-ivy-nxf2la. |
what is the solution for this? any work around @markostanimirovic? |
Even through there is an expectation that The question that I have is would you expect an error in the |
In my opnion, whatever happens in both - no exception must be swallowed. If it throws in |
Closed by #3533 |
Minimal reproduction of the bug/regression with instructions
That error ☝️ is silently caught which was painful to debug in my case. Here's a live repro on stackblitz
https://stackblitz.com/edit/angular-ivy-7jhxew?file=src%2Fapp%2Fapp.component.ts
Minimal reproduction of the bug/regression with instructions
To have an error thrown correctly.
Versions of NgRx, Angular, Node, affected browser(s) and operating system(s)
Other information
This very much looks like an issue I had with
ngrxPush
pipe here: #3100I would be willing to submit a PR to fix this issue
The text was updated successfully, but these errors were encountered: