[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => https://github.com/ngxs/store/blob/master/CONTRIBUTING.md
[ ] Other... Please describe:
When using both the ngxs/router-plugin and the ngxs/storage-plugin together in a project, the initial routing to a child component is canceled and a redirect to the blank state is triggered. See the following stackblitz for a reproduction: https://angular-tdus7x.stackblitz.io/
Navigate to either the page one or page two route, and refresh the page. On refresh, the app redirects back to the initial empty route.
When refreshing a page while both the ngxs/router-plugin and ngxs/storage-plugin are installed, the application remains on the current page and does not redirect to the empty route.
https://angular-tdus7x.stackblitz.io/
https://github.com/dallastjames/ngxs-routerstoragebug
Run the example provided. When navigated to either of the child pages a page refresh will redirect back to the empty route. Removing either the storage-plugin or the router-plugin fixes the issue, but as soon as both are added back, the problem returns.
As far as I've been able to tell the issue has to do with the initial NavigationStart event not being triggered when the app is not on the blank route. Logging the events that come from the router, There is a NavigationStart event triggered when the application is on the blank route. This always occurs, regardless of what plugins are installed. When navigating to child pages and refreshing, if both plugins are installed, this event is not seen and the app is redirected back to the blank route. If either of the plugins is removed, the NavigationStart event can then be seen when refreshing the page on a child route.
I added some logging in the router.state.ts file around the checkInitialNavigationOnce() method. The url received from the router events is always blank when the router plugin is installed with the storage plugin. Without the storage plugin, the value received here is correct and the method works correctly.
Router Events when only the router-plugin is installed:

Router Events when both the router-plugin and storage-plugin are installed:

Libs:
- @angular/core version: 8.1.3
- @ngxs/store version: tested on 3.5.0 and 3.5.0@dev
Browser:
- [x] Chrome (desktop) version 75
For Tooling issues:
- Node version: 10.15.3
- Platform: Linux
Please, tell me instructions what should I do to reproduce the problem. Instructions are step-by-step actions, but you've written an essay in the Minimal reproduction of the problem with instructions section :smile:
@arturovt haha sure.
Going from the git repo I posted above:
The url state information is lost and I am taken back to the root url.
NgxsStoragePluginModule.forRoot() in app.module.ts, the state is not lost on page refresh@arturovt what about that issue? what do you think?
i have the same issue, i commented out: NgxsStoragePluginModule.forRoot() and it works again. But i am unable to dispatch any Navigate-Events.
Exactly the same issue as described with v3.5.1
@arturovt is fixed?
I'm having the same issue, when the compiler reloads the application it goes back to the initial route. I tried installing HMR and the NgxsStoragePlugin but the behavior is still the same.
@rbasniak dunno but, routing is bit slow with this plugin NgxsRouterPluginModule.forRoot()
plugin version: 3.6.2
I just found out that in my case it was not a problem with the plugin, it was a bug in my application that as making it redirect to home at every refresh.
Most helpful comment
@arturovt haha sure.
Going from the git repo I posted above:
The url state information is lost and I am taken back to the root url.
NgxsStoragePluginModule.forRoot()in app.module.ts, the state is not lost on page refresh