GothenburgBitFactory / GothenburgBitFactory/taskchampion
Sync fails with IndexedDB due to weird Transaction semantics
- Dominant language
- Rust
- Stars
- 184
- Forks
- 41
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 7
Description
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.
Contributor guide
Assessment
This issue has not been assessed yet.