Skip to content

Fix cluster state on WebSocket reconnect with shared backend - #298

Merged
ravjotbrar merged 2 commits into
mainfrom
fix/cluster-reference-count
Apr 20, 2026
Merged

ravjotbrar merged 2 commits into
mainfrom
fix/cluster-reference-count

Conversation

@ravjotbrar

Copy link
Copy Markdown
Collaborator

Description

When multiple users share the same backend, a reconnecting user would receive updateClusterInfo instead of addCluster because the global clients map still held the existing GlideClusterClient. Since updateClusterInfo is a no-op on an empty frontend state, the cluster topology would never populate after reconnect.

In addition, clusterNodesRegistry was not cleaned up properly, this fix addresses that.

Changes:

  • returnExistingClusterClient now sends addCluster instead of updateClusterInfo, so a reconnecting client always rebuilds its cluster state from scratch

  • teardownConnection now accepts an optional clusterNodesRegistry and deletes the cluster entry when the last client for that cluster is closed — preventing stale entries
    from causing fan-out to disconnected nodes. This cleanup is skipped when USE_CLUSTER_ORCHESTRATOR=true since the registry is managed by the reconcile loop in that mode

  • closeConnection and the WebSocket close handler both pass clusterNodesRegistry to teardownConnection

Change Visualization

Include a screenshot/video of before and after the change.

…eletion

Signed-off-by: Ravjot Brar <ravjot.brar@improving.com>
Comment thread apps/server/src/index.ts Outdated
Signed-off-by: Ravjot Brar <ravjot.brar@improving.com>
@ravjotbrar
ravjotbrar merged commit 3c37c76 into main Apr 20, 2026
7 checks passed
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.

BUG: Cluster topology disappears when multiple users share the same backend

2 participants