AUR0227

Error Message

AUR0227: Computed mutating

Description

This error occurs when a computed property attempts to modify (mutate) observable state during its computation. Computed properties should be pure functions that only read values and return a result without causing side effects or mutations.

Why This Matters

Computed properties are designed to be:

  • Pure: Only read values, never modify them

  • Deterministic: Always return the same result for the same inputs

  • Side-effect free: Don't trigger other state changes

When a computed property mutates state, it can cause:

  • Infinite update loops

  • Unpredictable behavior

  • Performance issues

  • Hard-to-debug race conditions

Common Scenarios

Direct Property Mutation

Array/Object Mutations

Observable Mutations

Solutions

1. Keep Computeds Pure

2. Use Non-Mutating Array Methods

3. Move Mutations to Methods or Effects

4. Use Effects for Side Effects

Example: Refactoring Problematic Code

Debugging Tips

  1. Review Computed Logic: Ensure computed properties only read and calculate

  2. Check for Assignments: Look for any = assignments within computed getters

  3. Verify Array Methods: Use non-mutating methods like [...array].sort() instead of array.sort()

  4. Move Side Effects: Put mutations in methods, lifecycle hooks, or effects

  5. Use DevTools: Monitor observable changes to identify unexpected mutations

  • AUR0226 - Effect maximum recursion reached

  • AUR0224 - Invalid observable decorator usage

Last updated

Was this helpful?