-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
strictActionSerializability
does not work with RouterModule (and custom serializer)
#1834
Comments
Would like to fix this, but not sure of a good approach. @timdeschryver if you have any hints, they will be more than welcome 😃 |
Yes, we're aware of this and decided to hold of this because it would be a major breaking change. The Nx package also makes use of the unserializable properties. We made these checks opt-in so devs would have the time to transition. For more info see #1613 and #1630. I'm going to close this issue, but if you have any ideas or remarks feel free to share them 😃 |
My bad @timdeschryver, I was following the PR and the issue, but somehow I've missed this 😞. I thought it's just about the snapshot, just noticed the relevant part with:
I was not affected by the snapshot, I am using a custom serializer, but the router event still prevents me from using this. Is there any breaking change if only the part from above would be added ? That might be safe and will enable the usage for this scenario. Runtime checks rock! Awesome work! 👍 |
Sorry misread the question. Sadly, this would still be a breaking change because the methods available on the navigation events would all be removed: class Rectangle {
constructor(height, width) {
this.height = height;
this.width = width;
}
print() {
return {h: this.height, w: this.width}
}
}
const r = new Rectangle(10, 5);
r.print(); // {h: 10, w: 5}
const r2 = {...r};
r2.print(); // Uncaught TypeError: r2.print is not a function
`` |
As a solution we could use the spread operator, only if the runtime check is on. |
Something feels weird about modifying the router state in development based on runtime checks. If I recall correctly, the router events have a |
I do like your proposition more. Instead of stringifying the event, could we just have the The reason why I would like to have this feature is because otherwise the serializability checks are not use able in combination with @ngrx/router-store. |
Yea, I like that option better also to encourage usage of the checks. |
👍 I will make the necessary changes. |
@timdeschryver if @adrianfaciu wants to fix it, you can help him through it instead. |
It's ok, @timdeschryver already asked me :) He can go on with the changes. I'll have plenty of other issues to help with 😄 |
👍 |
In case any one else ends up here I fixed a bug
See docs - https://ngrx.io/guide/router-store/configuration#router-state-snapshot |
Thanks - pointed me in the right direction. Alternatively, you can disable serializability runtime checks as per: https://ngrx.io/guide/store/configuration/runtime-checks - see below:
|
Minimal reproduction of the bug/regression with instructions:
Steps to reproduce:
Due to #1630,
strictActionSerializability
cannot be used with the DefaultRouterStateSerializer, but it should work with a custom one, for example the one from the docs.Right now one get's an error: 'ERROR Error: "Detected unserializable action at "payload.event""''
This looks to be triggered in the isPlainObject method that is used in the getUnserializable method. All the router events extend the base RouterEvent class so the prototype check will fail
targetPrototype === Object.prototype
.GitHub repo here
Expected behavior:
Should be able to use
strictActionSerializability
with RouterModule.Versions of NgRx, Angular, Node, affected browser(s) and operating system(s):
Angular version: 8.0.0-rc.2
NgRx version: 8.0.0-beta.1
I would be willing to submit a PR to fix this issue
[x] Yes (Assistance is provided if you need help submitting a pull request)
[ ] No
The text was updated successfully, but these errors were encountered: