Skip to content

Certain @let values can mimic internal data structure, breaking basic runtime logic #59504

Description

@csutorasr

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

core

Is this a regression?

Yes

Description

Before hydration and using signals my code worked. I refactored it to use signals and incremental hydration and it broke. The error message was not really meaningful: Cannot add property i18nNodes, object is not extensible

I use apollo-angular which freezes every object in its state and results. The state cannot be modified.

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

Cannot add property i18nNodes, object is not extensible

The line where the error has happened is https://github.com/angular/angular/blob/4491704fbaec02db8eec5845ffbb200dbf2a0bf6/packages/core/src/hydration/i18n.ts#L660

Please provide the environment you discovered this bug in (run ng version)

NX 20.3.0
Angular 19.0.5
Angular SSR 19.0.6

Anything else?

Workaround:

Unfreeze the object using some hacky js code: const unfrozenObj = JSON.parse(JSON.stringify(obj));

Possible solutions:
Check before trying to set the values if the object is frozen using: Object.isExtensible(object).

  1. Throw an error that the state is not extensible and provide some information on the current component which has the error.
  2. Show a warning during development and provide some information on the current component which has the error. In production mode ignore it.
  3. Ignore setting the values without any warning.

I am very happy to code and make a PR on any of the solutions if the Angular team has decided.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2The issue is important to a large percentage of users, with a workaroundarea: coreIssues related to the framework runtimebugstate: has PR

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions