Skip to content

Add SyncedDocumentOptions#36

Merged
peachbits merged 2 commits intomasterfrom
matthew/synced-doc-preservation
Mar 18, 2026
Merged

Add SyncedDocumentOptions#36
peachbits merged 2 commits intomasterfrom
matthew/synced-doc-preservation

Conversation

@peachbits
Copy link
Contributor

@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 syncedDocument’s behavior when a document fails to clean by adding configurable fallback strategies and a failure callback; this can affect how corrupted data is handled and persisted during sync.

Overview
Adds optional SyncedDocumentOptions to syncedDocument, letting callers choose how to handle cleaner failures via cleanFailStrategy (reset to defaults or preserve last known-good value) and an onCleanFail notification callback.

Refactors sync cleaning to catch cleaner exceptions explicitly (instead of using asMaybe), and adds a comprehensive test suite covering creation/repair behavior, change events, and the new failure-handling modes; includes a CHANGELOG entry documenting the new options.

Written by Cursor Bugbot for commit 420dfbd. 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, { ... }>?

@peachbits peachbits merged commit 6c404e2 into master Mar 18, 2026
3 of 4 checks passed
@peachbits peachbits mentioned this pull request Mar 18, 2026
2 tasks
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