๐[BUG]: Error: You have forgotten to import the NGXS module!
See original GitHub issueAffected Package
Is this a regression?
Donโt know. First time Iโm seeing it.
Description
My server side rendered Angular 11 app exhibits a strange behavior where if Iโm sending many concurrent requests (like via a benchmark or a SEO crawler), it would start throwing ERROR Error: You have forgotten to import the NGXS module! errors in some of my components that use my stores. If Iโm just opening the page in the browser or sending a โslowโ benchmark it works fine.
At first I thought itโs because of my lazy loaded modular stores but then I reverted to an older commit with a monolith architecture and it exhibits the same behavior when multiple fast requests are hammering the app.
๐ฌ Minimal Reproduction
- Install Angular and NGXS
- Access an NGXS getter via
@Select()in some component - Setup server side rendering with
nguniversal - Send many concurrent requests for the page that accesses the NGXS store
๐ฅ Exception or Error
ERROR Error: You have forgotten to import the NGXS module!
at createSelectObservable (/path/to/my/app/dist/my-app/server/main.js:159278:15)
at GuideCategoriesComponent.get [as categories$] (/path/to/my/app/dist/my-app/server/main.js:159349:68)
at GuideCategoriesComponent_Template (/path/to/my/app/dist/my-app/server/main.js:255335:142)
at executeTemplate (/path/to/my/app/dist/my-app/server/main.js:74219:9)
at refreshView (/path/to/my/app/dist/my-app/server/main.js:74088:13)
at refreshComponent (/path/to/my/app/dist/my-app/server/main.js:75254:13)
at refreshChildComponents (/path/to/my/app/dist/my-app/server/main.js:73885:9)
at refreshView (/path/to/my/app/dist/my-app/server/main.js:74138:13)
at refreshEmbeddedViews (/path/to/my/app/dist/my-app/server/main.js:75208:17)
at refreshView (/path/to/my/app/dist/my-app/server/main.js:74112:9)
ERROR Error: You have forgotten to import the NGXS module!
at createSelectObservable (/path/to/my/app/dist/my-app/server/main.js:159278:15)
at GuidePostComponent.get [as categories$] (/path/to/my/app/dist/my-app/server/main.js:159349:68)
at GuidePostComponent.get postCategory$ [as postCategory$] (/path/to/my/app/dist/my-app/server/main.js:258896:81)
at GuidePostComponent_div_0_Template (/path/to/my/app/dist/my-app/server/main.js:258857:154)
at executeTemplate (/path/to/my/app/dist/my-app/server/main.js:74219:9)
at refreshView (/path/to/my/app/dist/my-app/server/main.js:74088:13)
at refreshEmbeddedViews (/path/to/my/app/dist/my-app/server/main.js:75208:17)
at refreshView (/path/to/my/app/dist/my-app/server/main.js:74112:9)
at refreshComponent (/path/to/my/app/dist/my-app/server/main.js:75254:13)
at refreshChildComponents (/path/to/my/app/dist/my-app/server/main.js:73885:9)
Environment
Libs:
- @angular/core version: 11.2.3
- @ngxs/store version: 3.7.1
- @nguniversal/common: 11.2.0
- @nguniversal/express-engine: 11.2.0
Browser:
- Screaming Frog Spider Crawler version 14.3
- Chrome (desktop) version 89.0.4389.90
- Chrome (Android) version XX
- Chrome (iOS) version XX
- Firefox version 85.0.2
- Safari (desktop) version 14.0.3
- Safari (iOS) version XX
- IE version XX
- Edge version XX
For Tooling issues:
- Node version: v14.4.0
- Platform: macOS 11.2.2
Issue Analytics
- State:
- Created 3 years ago
- Comments:11
Top Results From Across the Web
You've forgotten to import "NgxsSelectSnapshotModule" // the ...
The root cause of this issue is this file: https://github.com/ngxs/store/blob/master/packages/store/src/decorators/select/select-factory.ts.
Read more >ngxs - Bountysource
๐ [BUG]: 'Error: You have forgotten to import the NGXS module' after upgrading to 3.7.4 $ 0. Created 5 months ago in ngxs/store...
Read more >Unit Testing - NGXS
To perform a unit test we just dispatch the events, listen to the changes and perform our expectation. A basic test looks like...
Read more >Ngxs App Initializer - StackBlitz
Starter project for Angular apps that exports to the Angular CLI.
Read more >State Management in Angular Using NGXS - Auth0
We will look at how you can use NGXS to manage your application's state by ... Import the NgxsReduxDevtoolsPluginModule in our AppModule andย ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for the reply, it turned out to be an issue with path mapping in
tsconfig.json. Using explicit imports and avoiding shortened imports solved the underlying issue for my team.anyone solve this issue already ?