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

HMR breaks when calling dispatch on destroy #570

Open
Dima-Astreyko opened this issue Nov 24, 2022 · 0 comments
Open

HMR breaks when calling dispatch on destroy #570

Dima-Astreyko opened this issue Nov 24, 2022 · 0 comments

Comments

@Dima-Astreyko
Copy link

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

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

1 participant