Skip to content

front: replace ImmutableStateInvariantMiddleware check #6258

@clarani

Description

@clarani

Description and goal

In #5583, we had to disabled the ImmutableStateInvariantMiddleware check because the store was too big and the check took too much time. This check was used to guarantee that the store was immutable, and was fired each time the store changed (could take up to 270ms).
This check is only done on dev environment, it is deactivated on production.

To solve the warning, we had 2 quick solutions with ImmutableStateInvariantMiddleware:

  • either increase the threshold from 32ms to 300ms approx (but not good for the perf)
  • either deactivate the middleware

We chose to deactivate it as we use Immer to create our store slices and it improve the perfs (see reduxjs/redux-toolkit#415 (comment) and reduxjs/redux-toolkit#415 (comment)).

But nothing guarantees now that the store is immutable, we could do for instance:

const a = store.getState();
a.user = {};

To replace the check, possible solutions to evaluate:

  • make the root state an object.freeze object
  • use a new lib to check that each time we create the store, it is immutable

⚠️ be aware that some keys might be removed by #6025 and that the store size might decrease. But it might not solve the issue and reactivate the check will still impact the perfs.

Acceptance criteria

A new technical solution is found to guarantee the immutability of the store.

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