-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix Redux integration failing with reducer injection #16017
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
Comments
Only looking superficially at this, my main thought is whether there is anything that the Sentry SDK can even do here. Isn't this more an issue with redux toolkit and/or your setup? |
Override replaceReducer functiont so any lazy loaded injection will reinsert the sentry reducer in the chain
Hi @lforst, According to timdorr and markerikson :
According to Methuselah96, is it :
Here is a commit that follow their principles, by overriding the I have to admit I am not perfect in TS and not have a build environmlent right now to test it, but I think it may be the solution. |
An enhancer takes a store creator function as input ( The current Sentry Redux enhancer correctly follows this pattern (so it's a legit enhancer): return (next: StoreEnhancerStoreCreator): StoreEnhancerStoreCreator =>
<S = any, A extends Action = AnyAction>(reducer: Reducer<S, A>, initialState?: PreloadedState<S>) => {
// Enhancement logic
return next(sentryReducer, initialState);
}; However, you are correct that @AntoineDuComptoirDesPharmacies Do you want to contribute this and create a PR for this? If you do, please assign me as reviewer so I get a notification about it. |
Add a test to verify that redux enhancer is still calling setContext with updated store avec reducer being replaced
To keep correct typescript type, use "Proxy" instead of plain object. @s1gr1d I am wondering if we can do better than accessing the index [0] directly ?
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/react
SDK Version
9.9.0
Framework Version
18.2.0
Link to Sentry event
No response
Reproduction Example/SDK Setup
Steps to Reproduce
Reducers are added on runtime depending of the section of the app loaded by user.
Expected Result
Sentry Redux Enhancer should not be "evicted" when calling
replaceReducer
method and soconfigureScopeWithState
should continue to be called on state change.See this issue about how to code a redux enhancer that will remain even if
replaceReducer
is called :reduxjs/redux#4127
Actual Result
Function 'replaceReducer' fully remove the Sentry Redux Enhancer from the chain.
As a result, the method
configureScopeWithState
is no longer called on redux state change.Same problem occured here and likely to be the came cause :
The text was updated successfully, but these errors were encountered: