Skip to content

docs: storage error handling and the storage adapter contract#679

Open
darcyparker wants to merge 1 commit into
automerge:mainfrom
darcyparker:darcy/storage-error-contract
Open

docs: storage error handling and the storage adapter contract#679
darcyparker wants to merge 1 commit into
automerge:mainfrom
darcyparker:darcy/storage-error-contract

Conversation

@darcyparker

Copy link
Copy Markdown
Contributor

What

Adds a dev-docs page, packages/automerge-repo/dev-docs/storage-error-handling.md, documenting what happens when storage I/O fails and where the responsibility for reliability lies. This is the follow-up suggested in the review discussion on #676. Doc-only; no code changes.

Contents

  • What StorageSource guarantees: a failed save does not crash the process, and the change is retained in memory so a later save or reload re-persists it. It converts a fatal crash into a recoverable condition and does nothing more.
  • The storage adapter contract: adapters own robustness; retry and backoff are one consideration (not a mandate, and not always the best fit); escalation is the adapter's responsibility, since only the adapter knows its backend.
  • Reliability strategies: network redundancy via peers is usually the strongest lever, since a document synced to the repo instances you connect to is already durable in more than one place; adapter retry/backoff and other strategies (multi-backend write-through, a durable queue, reconciliation) are options to weigh.
  • Observability and alerting: failures surface via the pluggable logger (setLoggerFactory, shaped for console/pino/winston); shipping logs (for example via OpenTelemetry) to an alerting layer is a deployment concern owned by the application embedding automerge-repo.
  • Why there is no first-class storage error event: the logging path already exists and is configurable, escalation belongs in the adapter, and redundancy comes from the network; a custom LoggerFactory is the hook for programmatic handling.

Capture what StorageSource guarantees on a failed write (the process stays up, and the change is retained in memory so a later save or reload re-persists it), and the responsibilities that sit with storage adapters: recoverability, retry and backoff as one option among others, and escalation. Note the reliability strategies available, with network redundancy via peers as the primary lever, and that configuring observability and alerting is the embedding application's job via the pluggable logger (setLoggerFactory, console/pino/winston). No first-class storage-error signal is added.
@darcyparker darcyparker force-pushed the darcy/storage-error-contract branch from b6b2f24 to 627b7a0 Compare June 11, 2026 16:11
@msakrejda

Copy link
Copy Markdown
Collaborator

Cool, thanks! Broadly, I think these docs are good. I'm not sure if this is the right place for them. It might be, but we're not really doing that for other stuff. Other options:

I'll sleep on it.

@darcyparker

Copy link
Copy Markdown
Contributor Author

Cool, thanks! Broadly, I think these docs are good. I'm not sure if this is the right place for them. It might be, but we're not really doing that for other stuff. Other options:

I'll sleep on it.

NP - Use it as a reference. Feel free to close this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants