platform
platform copied to clipboard
Weird `component-store` initialization problem in route guards
Which @ngrx/* package(s) are the source of the bug?
component-store
Minimal reproduction of the bug/regression with instructions
https://stackblitz.com/edit/angular-ivy-hupmyu?devToolsHeight=33&file=src/app/local-store.ts
In the console: Error: LocalStore has not been initialized yet. Please make sure it is initialized before updating/getting.
Minimal reproduction of the bug/regression with instructions
The use-case might seem weird but I still think it's a legit one and should not fail.
It feels like the bug has something to do with the queue scheduler. Although, the problem only appears under some conditions (having nested routes with guards) which can be seen in the Stackblitz example.
Versions of NgRx, Angular, Node, affected browser(s) and operating system(s)
@ngrx/component-store: 14.3.2 @angular/core: 14.2.10
Other information
No response
I would be willing to submit a PR to fix this issue
- [ ] Yes
- [ ] No
This also happens to me without using get
directly - when I call patchState
serially a few times (inside a complicated observable pipe, which, I assume, executes queueScheduler somewhere).
Looks like the root cause is the same