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

You've forgotten to import "NgxsSelectSnapshotModule" // the NGXS module #103

Open
elegon32 opened this issue Feb 27, 2021 · 2 comments
Open

Comments

@elegon32
Copy link

elegon32 commented Feb 27, 2021

Description

We see in our server logs many of these 2 FATAL Errors on production and on non-production environments:

  • FATAL [main.js:xx] NgxsSelectSnapshotModuleIsNotImported [Error]: You've forgotten to import "NgxsSelectSnapshotModule"! at assertDefined (/opt/app/dist/server/main.js:xx:yy) at getStore
  • FATAL [main.js:xx] Error: You have forgotten to import the NGXS module! at createSelectObservable (/opt/app/dist/server/main.js:1:yy)

We clearly have imported both ngxs modules in AppModule and in the Feature Modules.
In App module:


NgxsModule.forRoot(
      [
      xxx....
      ],
      {
        developmentMode: !environment.production,
      },
    ),
    NgxsRouterPluginModule.forRoot(),
    NgxsFormPluginModule.forRoot(),
    NgxsSelectSnapshotModule.forRoot(),
    NgxsStoragePluginModule.forRoot({
         ...xxx
      },
    }),
    NgxsReduxDevtoolsPluginModule.forRoot({
      name: 'xxxx',
      disabled: environment.production,
    }),

in Feature Module:


    NgxsModule.forFeature([xxx, yyy]),
    NgxsSelectSnapshotModule,

It is a very huge project with many modules and components... And the errors are only happening via SSR, and there it happens rarely on our dev machines... When it does, though, we see a LOT of Error statements successively while no other component or module is complaing with an error. It is just ngxs.
It seems, that SSR still deliveres the html, and the Angular app loads still well on the client (including all ngxs stuff)

🔬 Minimal Reproduction

Ok. We found out how to reproduce:

  1. open a page in browser
  2. refresh
  3. quickly abort loading
  4. quickly refresh again
  5. --> many many FATAL Errors

Guess: This might be caused by angular destroying all stuff and both ngxs modules will clear the Injector onDestroy.
As the errors happens ONLY when we reload quickly after aborting (just aborting never creates the errors), it must be sth about angular universal still (re-?) using some components while ngxs already got rid of its injector reference.

🔥 Exception or Error


FATAL [main.js:2897] NgxsSelectSnapshotModuleIsNotImported [Error]: You've forgotten to import "NgxsSelectSnapshotModule"! 
at assertDefined (/opt/app/dist/server/main.js:2897:xx) 
at getStore (/opt/app/dist/server/main.js:2897:xx) 
at XXXComponent.get [as isXXX] (/opt/app/dist/server/main.js:2897:xx) 
at XXXComponent_Template (/opt/app/dist/server/main.js:2897:xx) 
at executeTemplate (/opt/app/dist/server/main.js:2897:xx) 
at refreshView (/opt/app/dist/server/main.js:2897:xx) 
at refreshComponent (/opt/app/dist/server/main.js:2897:xx) 
at refreshChildComponents (/opt/app/dist/server/main.js:2897:xx) 
at refreshView (/opt/app/dist/server/main.js:2897:xx) 
at refreshComponent (/opt/app/dist/server/main.js:2897:xx)

or....

FATAL [main.js:2897] Error: You have forgotten to import the NGXS module! 
at createSelectObservable (/opt/app/dist/server/main.js:1:xx) 
at AppComponent.get [as progress] (/opt/app/dist/server/main.js:1:xx) 
at AppComponent_Template (/opt/app/dist/server/main.js:2897:1625353) 
at executeTemplate (/opt/app/dist/server/main.js:2897:xx) 
at refreshView (/opt/app/dist/server/main.js:2897:xx) 
at refreshComponent (/opt/app/dist/server/main.js:2897:xx) 
at refreshChildComponents (/opt/app/dist/server/main.js:2897:xx) 
at refreshView (/opt/app/dist/server/main.js:2897:xx) 
at renderComponentOrTemplate (/opt/app/dist/server/main.js:2897:xx)
at tickRootContext (/opt/app/dist/server/main.js:2897:xx)

Environment


Libs:
    "@angular/core": "^11.0.6",
    "@ngxs/store": "^3.7.1",
    "@ngxs-labs/select-snapshot": "^2.0.1",

Browser: only on SSR
@elegon32
Copy link
Author

elegon32 commented Mar 1, 2021

Ok. We found out how to reproduce:

  1. open a page in browser
  2. refresh
  3. quickly abort loading
  4. quickly refresh again
  5. --> many many FATAL Errors

Guess: This might be caused by angular destroying all stuff and both ngxs modules will clear the Injector onDestroy.
As the errors happens ONLY when we reload quickly after aborting (just aborting never creates the errors), it must be sth about angular universal still (re-?) using some components while ngxs already got rid of its injector reference.

@elegon32
Copy link
Author

elegon32 commented Mar 4, 2021

This is the same issue as further explained here: ngxs/store#1723

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