decentraland / decentraland/godot-explorer
[Bug] Friends connection drops and reconnects every 2 seconds (floods Sentry)
- Dominant language
- Rust
- Stars
- 18
- Forks
- 19
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 43
Description
## What happens
After being logged in for about 30 seconds, the friends connection starts dropping and reconnecting every 2 seconds, and it never stops. In the logs it looks like this, repeating forever:
```
[FriendsPanel.SubscriptionState] subscription dropped — reconnecting in 2s
```
Because of this:
- **Sentry gets flooded.** Most of the "social" reconnect noise we see in Sentry comes from this loop — the same errors reported over and over, from every logged-in player, every few seconds.
- Friend online/offline status stops updating.
- The friends panel keeps refreshing for no reason, and we hit the server with useless requests every 2 seconds.
## Why it happens
Every 30 seconds the client re-subscribes to the friends streams (friendship, connectivity, blocks) on the same connection, "just in case". The problem: the RPC protocol has **no way to close a stream that is already open**, so the server still sees the old subscription as active. When the new subscription arrives, the server says "you already have one" and closes it right away. The client thinks the connection dropped, waits 2 seconds, subscribes again, gets closed again... forever.
The server even has a metric for this exact situation (`subscription_duplicates_total`) with a comment saying *"a sustained high rate on the metric indicates a client stuck re-subscribing"*. That client is us.
The Unity explorer doesn't have this problem because it follows one simple rule: **never re-subscribe while a stream is still alive.**
Bonus finding: the "empty BlockUpdate" events we were seeing are part of the same story. Before closing a duplicate stream, the server sends a small "stream closed because: duplicate subscription" note. Our protos are older and don't know that field, so it decodes as an empty update.
## How to reproduce
1. Log in with a real account (not guest).
2. Wait ~30 seconds.
3. Watch the logs: the drop/reconnect cycle starts and never stops.
Contributor guide
Assessment
This issue has not been assessed yet.