-
Notifications
You must be signed in to change notification settings - Fork 467
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
Always log reducers exception #263 #379
Always log reducers exception #263 #379
Conversation
Hey @Jerry-Hong, thanks for the PR!! I'm gonna make some minor adjustments to make sure that |
hmm just realized an issue that is probably a deal breaker to this: The alternative I'm looking into is using the old async rethrow Here's a first crack at it: #380 Any objections? |
I also remembered that catching all errors at this place prevents some errors that would have otherwise bubbled all the way back to the original place someone called e.g. if your epic listens for an action and then synchronously emits another one the error would have historically bubbled all the way back up: https://jsbin.com/dagoluw/edit?js,console // synchronously listen and emit
const pingEpic = action$ =>
action$.ofType('PING')
.mapTo({ type: 'PONG' });
const pingReducer = (state = { isPinging: false }, action) => {
switch (action.type) {
case 'PING':
return { isPinging: true };
case 'PONG':
throw new Error('BAD'); // <----------------------------------- error thrown
default:
return state;
}
};
// pretend this is in your UI or anywhere else in your app
try {
store.dispatch({ type: 'PING' });
} catch (e) {
// error bubbles all the way back up to here!
console.log('I CAUGHT THIS: ', e.message);
} |
+1 for async rethrow, it helps collecting error logs and send them through error tracking systems like Rollbar. As for the scenario depicted in #379 (comment) , try-catch on The main reason for this breakage is that RxJS is swallowing the error and waiting for TC39 to come up with a solution. For the time being, I think @Jerry-Hong 's PR and is an adequate temporary solution because:
Async re-throw, on the other hand, comes with the assumption that users may build an error logging mechanism around it. I also consider it adequate, as long as we document that things may change after TC39 has made up their mind. Update: I compared the 2 jsbin, and found that rx.js 5.5 actually throws, only 5.1~5.4 swallows |
Async rethrow error is good to me 👍 |
@MrOrz Thanks for chiming in! Glad some people are helping sanity check things. Can you clarify your position? At first it sounded like you async rethrow, then you wanted To clarify btw this bug still exists in the latest 5.5.3. There has been several attempts to fix it but each one only fixed particular cases of it. It's still possible to run into it, here's one: https://jsbin.com/lawipop/1/edit?js,console
I'm not on the core team anymore so I'm not speaking for them but it's my understanding that it hasn't been fixed because no one has been able to find the one solution "to rule them all", but not because anyone's waiting for TC39 to figure out the Observable swallowing behavior. So it's definitely a bug in v5. v6 may or may not have swallowing behavior depending on its release timeline but if it does it's almost certainly going to present them in the console/window.onerror somehow, similar to how Promises swallow but still show up in the console for debugging. My comment here goes into more detail. for anyone else who's curious. tl;dr the primary reason people hate complete swallowing is because it doesn't show up in the dev console and regardless of what goes down with TC39 and swallowing it seems 99% certain that the error will at the very least show up in the console, even if it's technically "swallowed". |
I've been going deeper down the rabbit hole. The core team already in fact merged a PR for the new v6 behavior of not rethrowing errors aka swallowing ReactiveX/rxjs#3062 Just like Promises it will still report the error into the console because it uses the This is mostly an FYI to the incoming changes. This is still a bug in v5, especially since it doesn't report anything in the console. I've spent a bunch of time trying to figure it out but so far everything I try breaks something else. |
@jayphelps thank you so much for digging into this deeply. I totally agree that in v5 it can be considered as a bug, and we might not get reliable error messages from RxJS before everything settles down in v6. If your concern is that @Jerry-Hong 's try-catch in If an extra |
@MrOrz I really appreciate the thanks! 🕺 I've been digging into this so deeply but it's pretty confusing with so many moving parts lol.
I agree. I'm also leaning to the extra console.error, but gonna give it a few days to settle. It's annoying, but so far seems like the safest option for everyone and two errors is better than no errors! Assuming that I can't figure out the rxjs bug itself before 😢 everything I try breaks something else. |
@jayphelps thx for really careful concerns about error handler, those can be complicated after all, appreciate your thinkings. |
@bjmin yep that's a possibility too. Will think it over some more. I just submitted a PR upstream to rxjs with a "fix" that seems to work for all the cases I've come across with. ReactiveX/rxjs#3161 I've published it as Don't get your hopes up just yet as fixes like these can be pretty controversial and fearful since so many people rely on rxjs it's easy to fix one thing but cause major issues for a much larger group of people 😆 |
looking forwards 2 next progress!.. thx |
but I am still wondering when to publish this fix version? |
@bjmin this particular PR won't make it unfortunately because it would prevent error reporting to |
@jayphelps i see, sorry for misunderstanding. i thought u would publish those fixes first, then wait until the rxjs accept a fix for 5.x version. u r right, that's reasonable. |
@jayphelps maybe i'll make a fork version and use it privately in my team. |
FYI rxjs 5.5.6 fixed the swallow issue ReactiveX/rxjs#3161 |
#263