Skip to content

RouterState is serialized by reference #3783

@bohoffi

Description

@bohoffi

Which @ngrx/* package(s) are the source of the bug?

router-store, store

Minimal reproduction of the bug/regression with instructions

A minimal reproduction example can be found at https://stackblitz.com/edit/angular-uqnf9c?file=src/app/routed.component.ts

The situation scribbled in the example originates from an application which started to implement @ngrx/store in combination with @ngrx/router-store using NavigationActionTiming.PostActivation

The problem with the RouterState serialized by reference is that with late navigation action timing the route data gets serialized (by reference) too.

Mutating route data somewhere else like via a member (see StackBlitz example) leads to
TypeError: Cannot add property child, object is not extensible

Minimal reproduction of the bug/regression with instructions

RouterState serialization should use a clone when serializing to prevent unintended mutation of store contents.

Versions of NgRx, Angular, Node, affected browser(s) and operating system(s)

NgRx: >= 14.3.2
Angular: >= 14.2.9

Other information

No response

I would be willing to submit a PR to fix this issue

  • Yes
  • No

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions