dispatch-decorator
dispatch-decorator copied to clipboard
HMR breaks when calling dispatch on destroy
I'm submitting a...
[ ] 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:
Current behavior
Hi, i faced with issue
- hmr enabled in project
- used dispatch action in destroy hook to clean/reset something
- on module replacement, i have an error:
[HMR] Update failed: Error: NG0205: Injector has already been destroyed.
at R3Injector.assertNotDestroyed (http://localhost:4200/vendor.js:42569:19)
at R3Injector.get (http://localhost:4200/vendor.js:42497:14)
at NgModuleRef.get (http://localhost:4200/vendor.js:53097:33)
at Object.get (http://localhost:4200/vendor.js:52774:35)
at lookupTokenUsingModuleInjector (http://localhost:4200/vendor.js:34491:39)
at getOrCreateInjectable (http://localhost:4200/vendor.js:34603:12)
at NodeInjector.get (http://localhost:4200/vendor.js:34778:16)
at localInject (http://localhost:4200/main.js:503:32)
at CounterFacade.wrapped (http://localhost:4200/main.js:374:109)
at CounterComponent.ngOnDestroy (http://localhost:4200/main.js:221:28)
Reason: dispatch decorator tried to inject Store via destroyed R3Injector and failed on it
Expected behavior
Dispatch decorator skip action in dev mode with enabled hmr on module reloading stage
Environment
Libs:
- @angular/core version: 13.2.3
- @ngxs/store version: 3.7.6