Navigation Menu

Skip to content
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

Error on upgrade to 5.0 in store-devtools #741

Closed
karptonite opened this issue Jan 23, 2018 · 11 comments
Closed

Error on upgrade to 5.0 in store-devtools #741

karptonite opened this issue Jan 23, 2018 · 11 comments

Comments

@karptonite
Copy link
Contributor

karptonite commented Jan 23, 2018

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Feature request
[ ] Documentation issue or request

What is the current behavior?

After upgrading to the new version of ngrx, I get the following error in my browser console:

core.js:1440 ERROR TypeError: Cannot read property 'state' of undefined
    at MapSubscriber.unliftState [as project] (store-devtools.es5.js:163)
    at MapSubscriber._next (map.js:79)
    at MapSubscriber.Subscriber.next (Subscriber.js:92)
    at ReplaySubject._subscribe (ReplaySubject.js:61)
    at ReplaySubject.Observable._trySubscribe (Observable.js:172)
    at ReplaySubject.Subject._trySubscribe (Subject.js:98)
    at ReplaySubject.Observable.subscribe (Observable.js:160)
    at Observable._subscribe (Observable.js:231)
    at Observable.subscribe (Observable.js:160)
    at MapOperator.call (map.js:57)

that line in store-devtools corresponds to the second line of this function:

/**
 * Provides an app's view into the state of the lifted store.
 * @param {?} liftedState
 * @return {?}
 */
function unliftState(liftedState) {
    var computedStates = liftedState.computedStates, currentStateIndex = liftedState.currentStateIndex;
    var state = computedStates[currentStateIndex].state;
    return state;
}

Expected behavior:

no Error.

Minimal reproduction of the problem with instructions:

I don't have a minimal repro yet. I assume it won't be trivial to reproduce, since it hasn't been seen before the release. I can say that our application makes extensive use of lazy loaded modules, including using StoreModule.forFeature in multiple modules.

Without StoreDevtools, there are no problems upgrading, as far as I can tell.

Version of affected browser(s),operating system(s), npm, node and ngrx:

Chrome Version 63.0.3239.132
ngrx 5
node 9.3.0

@mwawrusch
Copy link

Seeing the same behavior here.

@wesselvdv
Copy link

wesselvdv commented Jan 24, 2018

Same here, seems it's trying to access an index that's out of bounds. Also, seems like a duplicate of #624

@karptonite
Copy link
Contributor Author

Yeah, it may be a duplicate. Here is a bit more information:
image of state

currentStates is an array of length 1, but currentStateIndex is set to 1, hence the undefined error. Not sure what is going on in there, but it seems that it shouldn't be possible for currentStateIndex to be larger than the largest index on currentStates.

@karptonite
Copy link
Contributor Author

karptonite commented Jan 24, 2018

Update, I was able to fix this module by changing the order of my imports, as described here:
#624 (comment)

Specifically, I got the error when I had StoreModule.forFeature imports before StoreDevtoolsModule.instrument, and the error went away when I ensured that devtools were imported before the feature module.

I'm leaving this issue open, because I'm not certain this is not a bug, and because the visibility may help others who have the same issue upgrading.

@wesselvdv
Copy link

wesselvdv commented Jan 24, 2018

I can confirm it now works for me to!

@mwawrusch
Copy link

Unfortunately it does not work for me. The only way to not break is to put it like so:

    !environment.production ? StoreDevtoolsModule.instrument({name: 'name'}) : [],
    StoreModule.forRoot(reducers , { metaReducers }),

which unfortunately does not connect the store to the dev tools at all.

@WillPoulson
Copy link

Same here. I have everything in the correct order yet still getting this error.

And as @mwawrusch said. You can put it above the StoreModule however then it can't find the store at all...

Could really do with a solution to this asap as I'm trying to learn how to use ngrx and the dev tools would be a great visual aid.

@wesselvdv
Copy link

@mwawrusch @WillPoulson Any of you guys importing other modules beforehand that are creating feature states? That'll make sure this breaks too.

@WillPoulson
Copy link

@wesselvdv Nope, I only have one feature module and that gets imported after the state and dev tools.

@fToledo29
Copy link

fToledo29 commented Apr 11, 2018

Did someone find any solution? I'm having the same behavior in my project :-(

@vinothbabu
Copy link

This is not fixed right? any next releases have this one addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants