Skip to content

zero-swift: list a group's running clients in activeClients - #11

Merged
tmm merged 1 commit into
mainfrom
swift-active-clients
Oct 22, 2026
Merged

tmm merged 1 commit into
mainfrom
swift-active-clients

Conversation

@tmm

@tmm tmm commented Oct 22, 2026

Copy link
Copy Markdown
Member

Fixes a bug found by the bug sweep: two Zero instances in one client group, in one process (same user, storageKey and storage, e.g. two windows), broke each other on the server.

  • Before: initConnection sent activeClients with only the connecting client, so zero-cache deleted the other running client of the group along with its queries. A closed client was also never reported with deleteClients.
  • Now: the shared ReplicaDatabase tracks the running clients of the process (JS's ActiveClientsManager, without the Web Locks, since Swift coordinates within one process). activeClients lists the group's running clients, this one first, and when one closes, each other client of the group sends deleteClients for it once, if connected, as JS does.
  • Not ported: recording the closed client in deleted clients. JS's onDelete only sends the message.

Checked: the two sweep tests failed before and pass now. 161 Swift tests and the lint pass. A new E2E test, twoClientsOfAGroupBothKeepTheirQueries, fails on the old code (with ttl: .none) and passes against a real zero-cache.

Two Zero instances in one client group, in one process, list each other
in initConnection's activeClients, and the survivor sends deleteClients
for one that closes, as JS's ActiveClientsManager does.

Amp-Thread-ID: https://ampcode.com/threads/T-c513a037-a257-45e0-b9a9-15c15edfe859
Co-authored-by: tmm <tmm@tmm.dev>
@tmm
tmm force-pushed the swift-active-clients branch from 0d2fa09 to 99a9c9c Compare October 22, 2026 03:58
@tmm
tmm merged commit fcc95f0 into main Oct 22, 2026
9 checks passed
@tmm
tmm deleted the swift-active-clients branch October 22, 2026 04:08
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