Skip to content

Add SyncedDocumentOptions#36

Open
peachbits wants to merge 1 commit intomasterfrom
matthew/synced-doc-preservation
Open

Add SyncedDocumentOptions#36
peachbits wants to merge 1 commit intomasterfrom
matthew/synced-doc-preservation

Conversation

@peachbits
Copy link

@peachbits peachbits commented Feb 25, 2026

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none

Description

none

Note

Medium Risk
Changes the error-handling path for CouchDB document syncing and introduces configurable behavior that can affect what gets written back to the database when documents are malformed.

Overview
syncedDocument now accepts an optional SyncedDocumentOptions to control what happens when the provided cleaner throws during sync.

On cleaner failure, it can either reset the in-memory value to cleaner({}) (default) or preserve the last known-good doc, and it can invoke an onCleanFail callback (swallowing callback errors). A new test suite covers creation/repair behavior, onChange semantics, and both failure strategies, and the CHANGELOG documents the new option.

Written by Cursor Bugbot for commit e4edf3f. This will update automatically on new commits. Configure here.


Copy link
Contributor

@swansontec swansontec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small changes requested, but otherwise this seems reasonable.


type Config = ReturnType<typeof asConfig>

function makeMockDb(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the return value be DocumentScope<unknown>, and then put the return {} as any hack inside? That would make it clearer what this is supposed to mock.

type Config = ReturnType<typeof asConfig>

function makeMockDb(
store: { [id: string]: { _rev: string; [key: string]: unknown } } = {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be Record<string, { ... }>?

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