Skip to content

@nhtio/lucid-resourceful/private/utils/cache_error_handler

Process-wide registration + dispatch for the relation-cache error handler (onRelationsCacheError, ADR-009). Holds the host-supplied default handler and reports every runtime cache-infra/serialization failure to the effective handler (per-model → process-wide default → no-op), guarded and never awaited so a reporter can neither throw into nor delay a load/write.

Defaults to a no-op so the package stays dependency-neutral — it never imports a logger; the host wires onRelationsCacheError to its own logger / Sentry / metrics (or nothing).

Type Aliases

Type AliasDescription
RelationsCacheErrorHandlerHost-supplied observer invoked when a runtime relation-cache operation fails (ADR-009). Observe-only: its return value is ignored — it cannot change the fallback control flow — and a throw from it is swallowed.

Functions

FunctionDescription
getDefaultOnRelationsCacheErrorReads the currently-registered default handler. Exposed for completeness; prefer reportRelationCacheError.
reportRelationCacheErrorReports a runtime relation-cache failure to the effective handler (ADR-009).
resetDefaultOnRelationsCacheErrorClears the module-scoped default handler. Test-only hook: hosts must not call this at runtime. Mirrors resetRelationCacheTargets.
setDefaultOnRelationsCacheErrorRegisters (or clears) the process-wide default relation-cache error handler.