Skip to content

Sync fails with IndexedDB due to weird Transaction semantics #685

@Slug-Man

Description

@Slug-Man

When calling replica.sync() with IndexedDbStorage in a browser, sync fails with (in Chrome): InvalidStateError: Failed to execute 'objectStore' on 'IDBTransaction': The transaction has finished.

Root Cause:
The sync code in taskdb/sync.rs opens a single transaction and holds it open while:

  1. Reading from storage (IDB operations)
  2. Making HTTP calls to the sync server (network I/O)
  3. Writing back to storage (IDB operations)

IndexedDB transactions auto-commit when there are no pending IDB operations. During HTTP calls, the browser sees no pending IDB work and closes the transaction. When sync tries to write afterward, it fails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Ready

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions