-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
connect swallows errors in mapStateToProps (new bug in 8.0.0) #1942
Comments
Just tested - it worked fine in 7.2.8 Here's a 7.2.8 fork https://codesandbox.io/s/charming-firefly-coekps Stopped working in 8.0.0 alpha. |
This is likely due to the switch to I'd have to investigate at some point, but I'm not sure how much we'll be able to do here, and any further changes to Honestly the main advice here would be to not use |
React 18 still supports class components, and you'll need react-redux 8 for React 18. I understand your point though. Would be great if you could take a look someday! Thank you for your work. |
Sure. To be clear, I wouldn't see this as "blocking an upgrade" to React-Redux v8 + React 18. We actually are on both in https://github.com/replayio/devtools right now, and we do have a bunch of |
Yeah I completely agree, don't get me wrong. Just leaving a little bit of hope that maybe you'll be bored one day and will fix it anyway :) |
Edit: I was encountering something else. Selectors are called in various places by either |
I think we're running into something similar in our application. When we hit an error in a selector, the exception seems to get gobbled up here: react-redux/src/components/connect.tsx Lines 131 to 141 in 8cf538c
We were previously relying on that thrown error to bubble up and get caught by an error handler, but now our app won't re-render and won't show an error. I won't claim that this is the best pattern (the application code is pretty old at this point), but is there any way to let that error pass through? Or if we did switch to |
@rdonnelly : afraid I don't have the brain bandwidth to answer this one further atm. The logic in |
Just spent hours trying to figure out why my app was silently crashing and this was the reason. In my opinion this is a quite significant regression, at least enough for me to have to downgrade to 7.1.x for now. Clearly I really wish you'd reconsider the decision to not make further changes to |
Just a thought, would it be possible to log the error here if
Would still be breaking for anyone whose logic depends upon errors in selectors bubbling up but hopefully that's not very many. Not perfect but a minimal change that would at least make it easier to find the cause of silent crashes caused by this during development. |
@alexanderchr I'm open to PRs to improve this, but right now all the time and mental bandwidth I can scrape together for Redux work is focused on RTK 2.0 and the related major versions, so I don't have the energy to think about this one myself. (FWIW, I agree that changes in behavior between versions can be considered "breaking". But we never specifically documented or specified how |
@markerikson I appreciate that, at first I took it as if you were not even considering PRs. Fully understand that this is not your top priority. I think that unless you have a full formal specification of a library there will always be lots of common sense behavior that is nowhere documented but cannot be changed without causing a breaking change. I think that not swallowing errors in functions passed to the library is usually such behavior, but obviously understand that it's impossible to keep track of it all (and also a question of personal judgement). |
Any updates on this? This is blocking our upgrade path. Switching it useSelector isn't really an option for us at this point either |
@hipstersmoothie : no updates . Per above, all my efforts in the last year+ have gone to upgrading the Redux packages (RTK 2.0, etc), and reworking the "Redux Essentials" tutorial. I'm not ruling out future changes to If you or someone else would like to submit a PR, I'm open to looking at it. What specifically about the (Also, is there a specific reason why you can't migrate to |
(I work with @hipstersmoothie so I'll answer!) We haven't actually been able to confirm that this bug is happening to us in 8.1.3. We're seeing errors getting bubbled up to our react error boundaries as expected, just like in react-redux 7.x. The codesandbox links in the original post seem to be dead now, so I can't test the original repro case. I'm wondering if there was some specific context around when it failed that we're not capturing in our synthetic tests. So, hopefully this is a false alarm on our end!
Mostly the risks of large-scale refactoring jobs in complex codebases, i.e., ensuring that nothing breaks along the way, and that performance is not regressing. We have some fun custom wrappers for |
Yeah, I definitely understand the effort to do major migrations :) Out of curiosity, what sort of "custom |
One is related to error-tracking (we want errors thrown in mapStateToProps to be tracked to Sentry with specific additional metadata). The more interesting one modifies the behavior of |
What version of React, ReactDOM/React Native, Redux, and React Redux are you using?
What is the current behavior?
https://codesandbox.io/s/gifted-architecture-wr4f86?file=/src/App.js
What is the expected behavior?
This issue makes debugging code that's using react-redux really hard.
The expected behaviour is that the error is visible in console.
It worked fine in 7.2.8: https://codesandbox.io/s/charming-firefly-coekps
Which browser and OS are affected by this issue?
Windows, latest Chrome here. Probably affects all browsers.
Did this work in previous versions of React Redux?
The text was updated successfully, but these errors were encountered: