redux-devtools: Breaking changes after updating extension to v3
After updating the Redux Dev Tools extension (Chrome) to v3 this weekend, our app is no longer working when the extension is enabled. Still works on Firefox as the add on hasn’t been updated yet.
We use redux-most as middleware, like so:
import { createStore, compose, combineReducers } from 'redux'
import { combineEpics, createEpicMiddleware, createStateStreamEnhancer } from 'redux-most'
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
const epicMiddleware = createEpicMiddleware(
combineEpics([
appEpic,
... // other epics here
])
)
const store = createStore(
combineReducers({
appReducer,
... // other reducers here
}),
composeEnhancers(createStateStreamEnhancer(epicMiddleware))
)
export default store
And now when accessing state (using withState), instead of the regular state object being returned it looks something like this:
{
actionsById: {...},
committedState: undefined,
computedStates: [{...}],
currentStateIndex: 1,
isLocked: false,
isPaused: false,
monitorState: {},
nextActionId: 2,
skippedActionIds: [],
stagedActionIds: [0, 1, ...],
}
Where the actual state object can be located at the last index of computedStates
Does anyone have any ideas as to what happened here and how it could be resolved? Thanks
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 3
- Comments: 34 (15 by maintainers)
@Methuselah96 gotcha. Really appreciate your detective work and digging here!
It worked with 3.0.3. Thanks @Methuselah96 ✌🏻
The issue is: Redux 4.0.5 depends on
symbol-observable
as doesmost
.symbol-observable
polyfillsSymbol.observable
and so it doesn’t matter which one callssymbol-observable
first, because the first one to access will do the polyfill and therefore both libraries will share the same symbol.Redux 4.1.0 does not depend on
symbol-observable
and is instead just doing a ponyfill for the observable symbol. Therefore ifredux
is imported first, it sees thatSymbol.observable
is not set and decides to use'@@observable'
as the ponyfill. However whensymbol-observable
is imported later, it polyfillsSymbol.observable
and that is what is used bymost
. Because of that the ponyfill and polyfill observable symbol properties don’t match up andmost
crashes because it was expecting the Redux store to have theSymbol.observable
polyfill property.So it seems like Redux should polyfill
Symbol.observable
if it wants to remain compatibility with libraries that usesymbol-observable
(perhaps add back the dependency onsymbol-observable
for simplicity?).Thanks @Methuselah96 3.0.3 also fixes an issue we were having with accessing the observable manually using symbol-observable. Appreciate the quick turnaround!
@Methuselah96 Yes it crashed
@Methuselah96 Sure, just installed and it crashed with:
@Methuselah96 i will open something up tomorrow morning if that’s ok! Once again, thank you for all your help tonight! I’ll be back tomorrow!
Thanks for the info. My guess is that the reason it breaks with the extension but not with plain Redux is because the order of import is the Redux DevTools extension,
most
/RxJS, and then Redux. I have a fix in mind that I’ll try to get out today.Was the dependency causing any specific problems? It seems like adding a few bytes to the bundle size is easily worth it in this case in order to avoid the special instructions of having to import the polyfill first, any complications that arise from that, as well as any developer time spent trying to figure out why it’s broken. It’s a pretty bad gotcha and easily solved on the Redux side of things. I like getting rid of dependencies as much as the next person, but this one seems like a net positive.