{"record":{"id":"7fab32c57be815e9","repo":"emberjs/ember.js","slug":"cannot-update-a-frozen-trackedvalue-this-options","errorCode":null,"errorMessage":"Cannot update a frozen TrackedValue${this.#options.description ? ` (\\`${this.#options.description}\\`)` : ''}","messagePattern":"Cannot update a frozen TrackedValue(.+?)\\\\`\\)` : ''\\}","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@glimmer/validator/lib/tracked-value.ts","lineNumber":69,"sourceCode":"    this.set(value);\n  }\n\n  /**\n   * Function short-hand for reading `value`.\n   */\n  get = (): Value => {\n    return this.value;\n  };\n\n  /**\n   * Function short-hand for assigning `value`.\n   *\n   * Returns `true` if the value changed (and consumers were notified),\n   * `false` if the new value was equal to the current one.\n   */\n  set = (value: Value): boolean => {\n    if (this.#isFrozen) {\n      throw new Error(\n        `Cannot update a frozen TrackedValue${\n          this.#options.description ? ` (\\`${this.#options.description}\\`)` : ''\n        }`\n      );\n    }\n\n    if (this.#options.equals(this.#value, value)) {\n      return false;\n    }\n\n    this.#value = value;\n\n    DIRTY_TAG(this.#tag);\n\n    return true;\n  };\n\n  /**","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/emberjs/ember.js/blob/26f97246a8bf2e28edf26ac3093da2e86c04ffc5/packages/@glimmer/validator/lib/tracked-value.ts#L51-L87","documentation":"A TrackedValue can be frozen (via freeze() / createStorage freeze semantics) after which its `set` method refuses updates, because notifying consumers of a change on a frozen value is undefined behavior. If a description was provided when creating the value it is included in the message to identify the culprit.","triggerScenarios":"Calling `set(value)` on a TrackedCell/TrackedValue after `freeze()` was called on it, e.g. mutating a cached cell after its containing snapshot was frozen, or writing to a const-tracked storage in a DEBUG check.","commonSituations":"Trying to update a value captured inside a `cached` getter's frozen epoch; writing to storage created by a library that froze it intentionally; holding a stale reference to a cell that was frozen when a component finalized.","solutions":["Stop writing to that value after it is frozen — restructure so mutations happen before freezing.","Create a new TrackedValue (or cell) instead of updating the frozen one, and update consumers' references to it.","Check which code path calls freeze() on it (search the description string in the error) and remove the freeze if updates are intended."],"exampleFix":"// before\nlet cell = createStorage('my value', description('cell'));\ncell.value = 'a';\nfreeze(cell);\ncell.value = 'b'; // throws\n\n// after\nlet cell = createStorage('my value', description('cell'));\ncell.value = 'a';\nfreeze(cell);\nif (needsUpdate) {\n  cell = createStorage('b', description('cell'));\n}","handlingStrategy":"type-guard","validationCode":"function canSet(cell) {\n  return !cell.isFrozen; // expose/track freeze state if wrapping storage\n}\nif (canSet(myCell)) myCell.value = next;","typeGuard":"function isWritableCell(cell) {\n  return cell != null && typeof cell.set === 'function' && cell.isFrozen !== true;\n}","tryCatchPattern":"try {\n  cell.set(next);\n} catch (e) {\n  if (String(e.message).startsWith('Cannot update a frozen TrackedValue')) {\n    // replace the frozen value with a new TrackedValue instead\n  } else throw e;\n}","preventionTips":["Treat frozen TrackedValues as immutable snapshots; allocate a new one for updates.","Perform all mutations before calling freeze().","Give every TrackedValue a description so error messages identify it instantly.","Audit `cached` getters: never write to tracked storage read during caching."],"tags":["glimmer","validator","reactivity","immutability","tracked-value"],"backgroundTag":"write-to-frozen-value","analyzedSha":"26f97246a8bf2e28edf26ac3093da2e86c04ffc5","analyzedAt":"2026-09-01T05:01:28.182Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}