angular/angular · error · RuntimeError

MANAGED_METADATA_LAZY_CREATION

MANAGED_METADATA_LAZY_CREATION

Error message

Managed metadata cannot be created lazily

What it means

Error "Managed metadata cannot be created lazily" thrown in angular/angular.

Source

Thrown at packages/forms/signals/src/field/metadata.ts:67

                computed(() => logic.compute(this.node.context)),
              );
              this.metadata.set(key, result);
            }
          }
        }),
      );
    } finally {
      if (wasInParams) ɵsetInParamsFunction(true);
    }
  }

  /** Gets the value of an `MetadataKey` for the field. */
  get<T>(key: MetadataKey<T, unknown, unknown>): T | undefined {
    // We create non-managed metadata lazily, the first time they are accessed.
    if (this.has(key)) {
      if (!this.metadata.has(key)) {
        if (key.create) {
          throw new RuntimeError(
            RuntimeErrorCode.MANAGED_METADATA_LAZY_CREATION,
            ngDevMode && 'Managed metadata cannot be created lazily',
          );
        }
        const logic = this.node.logicNode.logic.getMetadata(key);
        this.metadata.set(
          key,
          computed(() => logic.compute(this.node.context)),
        );
      }
    }
    return this.metadata.get(key) as T | undefined;
  }

  /** Checks whether the current metadata state has the given metadata key. */
  has(key: MetadataKey<any, any, any>): boolean {
    // Metadata keys get added to the map lazily, on first access,
    // so we can't rely on checking presence in the metadata map.

View on GitHub (pinned to 51cb07e980)

Solutions

  1. Create managed metadata eagerly via the metadata definition API instead of trying to define it lazily inside a getter or deferred callback.

When it happens

Trigger: Thrown at packages/forms/signals/src/field/metadata.ts:67 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of angular/angular@51cb07e980 (2026-08-22). Data as JSON: /api/errors/98e416de09a4d392. Report an issue: GitHub.