Skip to content

Commit 48ca692

Browse files
tmmampagent
andauthored
zero-swift: client and storage fixes from the bug sweep (#13)
* test(zero-swift): sweep tests for swift-client-fixes Amp-Thread-ID: https://ampcode.com/threads/T-c513a037-a257-45e0-b9a9-15c15edfe859 Co-authored-by: tmm <tmm@tmm.dev> * fix(zero-swift): a poke that changes nothing marks got queries authoritative As in zero.ts, the poke callback marks the got queries authoritative after rep.poke, even when the poke is a no-op, if the socket it came on is still the current one. An empty first poke after a reconnect or relaunch left views and preloads incomplete. Amp-Thread-ID: https://ampcode.com/threads/T-c513a037-a257-45e0-b9a9-15c15edfe859 Co-authored-by: tmm <tmm@tmm.dev> * fix(zero-swift): <= and >= filters never match NaN JS compareValues returns a - b, which is NaN for a NaN operand, so <= and >= are false. compare keeps its total order for sorting. Amp-Thread-ID: https://ampcode.com/threads/T-c513a037-a257-45e0-b9a9-15c15edfe859 Co-authored-by: tmm <tmm@tmm.dev> * fix(zero-swift): storage failures reach every client and busy writes are retried - Every client sharing a ReplicaDatabase hears about a write failure; a closed client is removed. - SQLiteStore stops writing at the first failure, so writes queued before it don't land after it. - SQLITE_BUSY/LOCKED is not a storage failure (classifySQLiteError): the ops are kept and written with the next write. - A read failure loading the client group in initClient is reported and moves the client to memory, as for a failed open. - The memory fallback after a failed open is shared by name, like .memory (fallbackStoreProvider, MemStore). - Drop the two SweepStorageTests for active clients, fixed on another branch. Amp-Thread-ID: https://ampcode.com/threads/T-c513a037-a257-45e0-b9a9-15c15edfe859 Co-authored-by: tmm <tmm@tmm.dev> * test(zero-swift): await a task instead of a semaphore in the busy test macOS rejects DispatchSemaphore.wait() in an async context. Amp-Thread-ID: https://ampcode.com/threads/T-c513a037-a257-45e0-b9a9-15c15edfe859 Co-authored-by: tmm <tmm@tmm.dev> --------- Co-authored-by: Amp <amp@ampcode.com>
1 parent a548803 commit 48ca692

9 files changed

Lines changed: 1742 additions & 27 deletions

File tree

‎.changeset/client-fixes.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'zero-swift': patch
3+
---
4+
5+
A first poke that changes nothing after a reconnect or relaunch completes the got queries, as in JS. `<=` and `>=` filters no longer match `NaN`. Storage: every client sharing a database hears about a write failure, and a closed client doesn't; writes queued before a failure no longer land after it; a database busy past the busy timeout is retried by the next write instead of being a storage failure; a read failure loading the client group is reported through `onStorageFailure` and moves the client to memory; and the memory fallback after a failed open is shared by name in the process, like `.memory`.

0 commit comments

Comments
 (0)