Closed xutzin closed 2 years ago
Got the same issue. Only happens during testing. Works fine in build and development. When i use the store everything works. If i use the @Select annotation than it fails.
I'm not sure if it's the same issue, but in my case there's another issue encountered during runtime.
Uncaught TypeError: Cannot set property ɵfac of function OrxUserNgXsState(<omitted>... } which has only a getter
at 80341 (user.ngxs.state.ts:23:2)
at __webpack_require__ (bootstrap:19:1)
at 73844 (inventory.ngxs.actions.ts:12:2)
at __webpack_require__ (bootstrap:19:1)
at 79878 (main.js:16:93)
at __webpack_require__ (bootstrap:19:1)
at 26746 (app.component.html:3:15)
at __webpack_require__ (bootstrap:19:1)
at 28940 (environment.ts:17:71)
at __webpack_require__ (bootstrap:19:1)
I added another application main-app
in https://stackblitz.com/edit/angular-ivy-vgtlgq as an example for the issue above
Thank you for the thorough bug report! @arturovt is having a look into it. If anyone is experiencing this issue as well, then please mention your Angular version just in case that is relevant.
I am having the same issue Libs:
Same here, Angular 13 and ngnx/store 3.7.4. Forcing version to 3.7.3 made tests runable again.
I have the following issue with 3.7.4 but 3.7.3 of @ngxs/store as well. Angular v14.0.1
Error: node_modules/@ngxs-labs/actions-executing/lib/actions-executing.module.d.ts:7:97 - error TS2339: Property 'ɵbc' does not exist on type 'typeof import("C:/localRepositories/NHIA/Eclaims 2.0/eclaims.vetting.client/eclaims-vetting/node_modules/@ngxs/store/ngxs-store")'.
7 static ɵmod: ɵngcc0.ɵɵNgModuleDeclaration<NgxsActionsExecutingModule, never, [typeof ɵngcc1.ɵbc], never>;
This is happening for me too, version 3.7.4. after upgrading dependencies for angular 12. As it has been already mentioned, forcing 3.7.3 works fine again.
@xutzin are you able to install the 3.7.4-dev.master-310a613
version and give it a try? Just update all packages as follows:
"@ngxs/store": "3.7.4-dev.master-310a613",
"@ngxs/storage-plugin": "3.7.4-dev.master-310a613",
...
Thank you all for taking the time on this issue.
I tried version 3.7.4-dev.master-310a613
and the results are as follows:
Branch (https://github.com/xutzin/angular-ngxs) |
NgXs Version | Error encountered during test Cannot redefine property: ɵfac |
Error encountered during runtime Cannot set property ɵfac of ... |
---|---|---|---|
master | 3.7.3 | ||
issue-3.7.4-cannot-set-property-fac | 3.7.4 | x | x |
issue-3.7.4-dev-cannot-set-property-fac | 3.7.4-dev.master-310a613 | x |
After a lengthy discussion, we decided to deprecate the Select decorator since it has impossible bugs to fix (just because Angular itself doesn't allow it). We're also planning to drop it in the future. It's complicated to maintain since we have to invest a lot of time into a single Select decorator rather than focusing on other essential issues. It's not type-safe. It has problems in server-side rendering and module federation. We tried to fix the server-side rendering issue initially, leading to a dead end.
For now, start replacing the Select decorator with store.select
. You also shouldn't have any issues with 3.7.4
if you drop Select decorator usages.
After a lengthy discussion, we decided to deprecate the Select decorator since it has impossible bugs to fix (just because Angular itself doesn't allow it). We're also planning to drop it in the future. It's complicated to maintain since we have to invest a lot of time into a single Select decorator rather than focusing on other essential issues. It's not type-safe. It has problems in server-side rendering and module federation. We tried to fix the server-side rendering issue initially, leading to a dead end.
For now, start replacing the Select decorator with
store.select
. You also shouldn't have any issues with3.7.4
if you drop Select decorator usages.
Hi, i'm having the same problem. Could you give me an example of how to do this switch between the Select decorator and the store.select?
I currently use it like this:
@Select(SesionState.getSesion)
sesion$: Observable
And then access it like this:
_this.sesion$.pipe( takeUntil(this.unsubscribeBase)) .subscribe( sesion => {
// Do stuff
});_
Thanks!
@mcrtricolor
constructor(store: Store) {
this.session$ = store.select(SesionState.getSesion);
// Use `this.session$` as you would when using @Select
}
If you are not referencing the session$
property in the template or in your component code, you could directly do:
store.select(SesionState.getSesion).pipe(takeUntil(this.unsubscribeBase)).subscribe(sesion => {
// Do stuff
});
Thanks axel! It was a big change in the app but it worked!
Thanks again for your quick response.
Great news! v3.7.5 has been released and it includes a fix for this issue. We are closing this issue, but please re-open it if the issue is not resolved. Please leave a comment in the v3.7.5 release discussion if you come across any regressions with respect to your issue.
Also, a specific note regarding this issue: Our recommendation to move away from the decorator still stands but we decided to only introduce the deprecation message in v3.8 because we will be providing a cleaner alternative to the decorator that does not require injecting the store.
Affected Package
@ngxs/store
Is this a regression?
Yes, the previous version in which this bug was not present was: 3.7.3
Description
extends ShaBaseDialog
or commenting out@Select(...) account$
can make the errors go away🔬 Minimal Reproduction
https://stackblitz.com/edit/angular-ivy-vgtlgq
$ ng test @shared/error
🔥 Exception or Error
Environment