-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
store-devtools: cannot read property 'state' of undefined #624
Comments
@alex-okrushko we are looking into this issue. Is there a certain sequence of events you can reproduce that triggers this issue? |
Not 100% certain, but it appears that StoreDevtoolsModule.instrument({maxAge: 25}) was being imported twice. |
With one StoreDevtoolsModule everything works. |
@alex-okrushko Yes. How was the second StoreDevtoolsModule introduced? Through another module imported lazily? We could add a guard to prevent it from being loaded more than once, but I'd like to understand how it came in first. |
In the same NgModule through unusual way: // foo.ts
export const REQUIRED_MODULES = [
StoreModule.forRoot({}),
EffectsModule.forRoot([]),
StoreDevtoolsModule.instrument({maxAge: 25}),
];
// app_module.ts
import {REQUIRED_MODULES} from './foo.ts';
@NgModule({
declarations: [ ],
imports: [
...REQUIRED_MODULES,
BrowserAnimationsModule,
HttpModule,
StoreDevtoolsModule.instrument({maxAge: 25}),
],
})
export class AppModule {} |
I'm having this problem. StoreDevtoolsModule is only being imported once. |
@ccpony provide a repo with a reproduction of this issue |
For our part, it was only being provided once as well. |
Yes, I'll prepare a repo. However, what I can tell you now is that the error is triggered on the following line of code:
...which produced the "cannot read property 'suppliers' of undefined" in the browser. |
@benlesh It was provided twice. I removed the second installation. |
@ccpony |
Thank you. I opened a new issue. |
I eliminated "cannot read property 'state' of undefined" error by changing import sequence in app.module.ts. imports: [ |
I had the same issue here. Fixed it by changing the import sequence (import feature module after store and store devools module) Before (with Error):
After (solved)
|
Workaround didn't work for me. I downgraded to 4.x for now. All great with 4. |
Downgrade to 4.1.1 also worked for me. 5.0.0 produces an error. Here is a branch to reproduce/inspect the error: |
I tried @dfreier 's idea, no luck. I changed all my modules and the app module to import the store first, but i'm still getting the error then in my feature component, I select from the store with this method imported:
and in my html I have the async pipe and the safe operator: Downgraded to Angular 4 and everything works great :/ maybe I did not import in the correctly suggested order?
feature module:
|
I was having the same issue after upgrading my ngrx modules to 5.0.0, and @dfreier 's solution worked for me |
Some feedback please: I've experienced "cannot read property 'x' of undefined" and the problem is the I don't know how to debug it. Ultimately, if I'm able to find the problem, it's largely by trial and error. Proceeding with ngrx and angular 5 is daunting for me because reactive programming seems to be very difficult to debug. How do you all deal with that issue (other than peppering your code with .do functions)? |
Here is a very simple reproduction: https://stackblitz.com/edit/ngrx-624-repro?file=app/app.module.ts StoreModule.forRoot({ count: counterReducer }),
StoreDevtoolsModule.instrument({ maxAge: 25, }), Not working: StoreModule.forRoot({ }),
CounterModule,
StoreDevtoolsModule.instrument({ maxAge: 25, }), Still not working with @dfreier's proposal: StoreModule.forRoot({ }),
StoreDevtoolsModule.instrument({ maxAge: 25, }),
CounterModule, |
hmmm. I'm still getting this issue after getting the latest |
The store-devtools are not updated due to ngrx/platform#624
The store-devtools are not updated due to ngrx/platform#624
The store-devtools are not updated due to ngrx/platform#624
The store-devtools are not updated due to ngrx/platform#624
Is it expected that 5.1 fixes this? It does not appear to be the case for me. I get the state is undefined error as seen in #777 (marked duplicate of this). Workarounds above do not help me. store 4.1.1 worked fine. |
Actually I was able to work around by rearranging my module imports. I had a service that referenced a selector. Moving that service module above the reducers/effects module fixed it. Should the ordering of module imports actually matter? |
@bufke yes, upgrading to 5.1 should fix the issue. Ordering of imports does matter when mixing NgModule and ModuleWithProviders. The latest release makes the order of dependencies more explicit. |
The store-devtools are not updated due to ngrx/platform#624
The store-devtools are not updated due to ngrx/platform#624
The store-devtools are not updated due to ngrx/platform#624
The store-devtools are not updated due to ngrx/platform#624
The store-devtools are not updated due to ngrx/platform#624
The store-devtools are not updated due to ngrx/platform#624
The store-devtools are not updated due to ngrx/platform#624
The store-devtools are not updated due to ngrx/platform#624
The store-devtools are not updated due to ngrx/platform#624
The store-devtools are not updated due to ngrx/platform#624
The store-devtools are not updated due to ngrx/platform#624
The store-devtools are not updated due to ngrx/platform#624
The store-devtools are not updated due to ngrx/platform#624
The store-devtools are not updated due to ngrx/platform#624
The store-devtools are not updated due to ngrx/platform#624
The store-devtools are not updated due to ngrx/platform#624
The store-devtools are not updated due to ngrx/platform#624
The store-devtools are not updated due to ngrx/platform#624
The store-devtools are not updated due to ngrx/platform#624
The store-devtools are not updated due to ngrx/platform#624
The store-devtools are not updated due to ngrx/platform#624
The store-devtools are not updated due to ngrx/platform#624
The store-devtools are not updated due to ngrx/platform#624
I'm submitting a...
What is the current behavior?
After syncing the latest ngrx into Google I have one of the tests failing (it's bootstrapping entire
AppModule
and hasStoreDevtoolsModule.instrument({maxAge: 25})
as part of imports). The test fails to initialize, so none of the actual test code is executed yet.The issue is surfaced in
unliftState
whencomputedStates
has length of 2, yetcurrentStateIndex
is 2 as well, and thuscomputedStates[currentStateIndex]
returnsundefiend
.This is what was the state leading up to this call:
Expected behavior:
Minimal reproduction of the problem with instructions:
Version of affected browser(s),operating system(s), npm, node and ngrx:
Other information:
The text was updated successfully, but these errors were encountered: