Remove adapter connection mem - #30
Merged
Merged
Conversation
Drop getConnections() from Adapter, Server, Swoole, and Workerman, and remove Swoole's private self::$connections mirror. Tracking the set of live fds belongs to the calling layer, not the transport library. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01245mLhHWfmjZejiua8wvMP
The test servers now maintain their own $connections set in onOpen/onClose and use it for broadcast and the /info count, replacing the removed $server->getConnections(). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01245mLhHWfmjZejiua8wvMP
phpstan (level max) flagged the $server use as unused after the /info count switched from $server->getConnections() to the local $connections set. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01245mLhHWfmjZejiua8wvMP
Greptile SummaryThe PR removes duplicated connection tracking and the
Confidence Score: 5/5The PR appears safe to merge because no blocking failure remains. No blocking failure remains. Important Files Changed
Reviews (2): Last reviewed commit: "test: drop unused $server from onRequest..." | Re-trigger Greptile |
abnegate
approved these changes
Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The connection fd (connection id) was being stored in two layers at once:
self::$connectionsmap (fd => true), written onopenand cleared onclose, exposed throughgetConnections().Realtimeadapter) — keeps its own$connectionsmap keyed by the same fd, holding the real per-connection state (projectId, roles, channels, authorization, presences, …).Both maps maintain the same keyset of live fds. The library's copy is pure duplication: it stores nothing the caller doesn't already have, and consumers that own a richer connection registry (appwrite doesn't call
getConnections()at all) end up tracking every fd twice.Notably, the Workerman adapter never had this problem — its
getConnections()read Workerman's ownTcpConnection::$connectionsregistry rather than maintaining a private mirror. Only Swoole duplicated the bookkeeping.Change
Tracking the set of live connections belongs to the calling layer, not a generic transport library. This PR removes that responsibility from the library entirely:
getConnections()fromAdapter,Server,Swoole, andWorkerman.self::$connectionsmirror and theonOpen/onClosebookkeeping that maintained it.$connectionsset (populated inonOpen/onClose) for broadcast and the/infocount — demonstrating the intended pattern: the consumer owns the registry.Impact
getConnections()and already maintains its own connection map.Server::getConnections(); such callers must track connections themselves via theonOpen/onClosecallbacks. Warrants a version bump when tagged.