Title: Fix Redux integration failing with reducer injection · Issue #16017 · getsentry/sentry-javascript · GitHub
Open Graph Title: Fix Redux integration failing with reducer injection · Issue #16017 · getsentry/sentry-javascript
X Title: Fix Redux integration failing with reducer injection · Issue #16017 · getsentry/sentry-javascript
Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using the latest SDK release https://github.com/...
Open Graph Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
X Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/16017
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Fix Redux integration failing with reducer injection","articleBody":"### Is there an existing issue for this?\n\n- [x] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues\n- [x] I have reviewed the documentation https://docs.sentry.io/\n- [x] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases\n\n### How do you use Sentry?\n\nSentry Saas (sentry.io)\n\n### Which SDK are you using?\n\n@sentry/react\n\n### SDK Version\n\n9.9.0\n\n### Framework Version\n\n18.2.0\n\n### Link to Sentry event\n\n_No response_\n\n### Reproduction Example/SDK Setup\n\n```javascript\nimport { configureStore } from '@reduxjs/toolkit';\nimport { combineReducers } from 'redux';\nimport createSagaMiddleware from 'redux-saga';\nimport * as Sentry from '@sentry/react';\n\nfunction createReducer(injectedReducers = {}) {\n const rootReducer = combineReducers({\n global: globalReducer,\n ...injectedReducers,\n });\n\n return rootReducer;\n}\n\n\n[...]\n\n const initialState = {};\n\n const sagaMiddleware = createSagaMiddleware();\n\n const sentryReduxEnhancer = Sentry.createReduxEnhancer({\n configureScopeWithState: (scope, state) => {\n console.log(\"configurescope\", state);\n },\n });\n\n const store = configureStore({\n preloadedState: initialState,\n reducer: createReducer(),\n middleware: (getDefaultMiddleware) => {\n return getDefaultMiddleware().concat(sagaMiddleware)\n },\n enhancers: (getDefaultEnhancers) => {\n return getDefaultEnhancers().concat(sentryReduxEnhancer);\n },\n });\n\n[...]\n\nconst injectedReducers= {\n newKey : (state, action) => {\n // simplification just for the reproducer\n return state;\n }\n}\n\nstore.replaceReducer(createReducer(injectedReducers));\n```\n\n### Steps to Reproduce\n\n1. Code an app using code splitting for reducer injection (See : https://redux.js.org/usage/code-splitting#reducer-injection-approaches).\nReducers are added on runtime depending of the section of the app loaded by user.\n2. Load the app and go to the lazy loaded reducer section\n3. Create a sentry issue that will upload redux state and check that your event redux state is missing keys/values modified after the reducer injection\n\n### Expected Result\n\nSentry Redux Enhancer should not be \"evicted\" when calling `replaceReducer` method and so `configureScopeWithState` should continue to be called on state change.\n\nSee this issue about how to code a redux enhancer that will remain even if `replaceReducer` is called : \nhttps://github.com/reduxjs/redux/issues/4127\n\n### Actual Result\n\nFunction 'replaceReducer' fully remove the Sentry Redux Enhancer from the chain.\nAs a result, the method `configureScopeWithState` is no longer called on redux state change.\n\nSame problem occured here and likely to be the came cause : \n* https://github.com/getsentry/sentry/issues/22778","author":{"url":"https://github.com/AntoineDuComptoirDesPharmacies","@type":"Person","name":"AntoineDuComptoirDesPharmacies"},"datePublished":"2025-04-09T10:47:06Z","url":"https://github.com/getsentry/sentry-javascript/issues/16017"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2b5c343e-63b1-b744-cb5d-64bac5af0143 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AF9A:BCD50:16E688:1FBDA7:6B073A09 |
| html-safe-nonce | 180ebfce641db5d7091be4a4f8f25bff1a7b82cd082bb5d9aef3201d33f802df |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRjlBOkJDRDUwOjE2RTY4ODoxRkJEQTc6NkIwNzNBMDkiLCJ2aXNpdG9yX2lkIjoiNDI2NTM2NTE5MzQ4NTY2MjcyOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ea7971a4e010bebdd9c0c397b9dcae6848ef61accdc063da559c4ca3c9c966a4 |
| hovercard-subject-tag | issue:2982415626 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/16017/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d3bb4b9fea3a6669722b037527bf87b576c644cb6bedba4d6551f0629f9e3bf7/getsentry/sentry-javascript/issues/16017 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d3bb4b9fea3a6669722b037527bf87b576c644cb6bedba4d6551f0629f9e3bf7/getsentry/sentry-javascript/issues/16017 |
| og:image:alt | Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | AntoineDuComptoirDesPharmacies |
| hostname | github.com |
| expected-hostname | github.com |
| None | d97a1befc96fc1512839eca15eb541061d491301144c9168e2985a8580319a49 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d28643426bfe8d1692f8788961b8217e9003f493 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width