bug: /v3/sync does not appropriately throttle presence changes #828

Open
opened 2025-05-15 17:17:16 +00:00 by nex · 1 comment
Owner

In v3.rs, calling /v3/sync will only prevent new presence updates from being broadcast if the presence status remains unchanged.

hitting /v3/sync calls this code, which consequently calls ping_presence.
Pinging presence only prevents an immediate update if the existing presence is the same as the new one.

This if statement does not apply, meaning that the new presence is sent immediately, which may result in (at best) flickering presence, or even (at worse) presence storm.

The solution here would likely be to buffer presence changes and apply the same timeout period regardless, or simply drop changes that are too quick, or even just not federate them.

In v3.rs, calling /v3/sync will only prevent new presence updates from being broadcast if the presence status remains unchanged. hitting `/v3/sync` calls [this code](https://forgejo.ellis.link/continuwuation/continuwuity/src/commit/e71138ab6ffbea621120c41bafb1c65c7b1a3e39/src/api/client/sync/v3.rs#L127-L132), which consequently calls `ping_presence`. Pinging presence only prevents an immediate update if the existing presence is the same as the new one. [This if statement](https://forgejo.ellis.link/continuwuation/continuwuity/src/commit/d8311a5ff672fdc4729d956af5e3af8646b0670d/src/service/presence/mod.rs#L117) does not apply, meaning that the new presence is sent [immediately](https://forgejo.ellis.link/continuwuation/continuwuity/src/commit/d8311a5ff672fdc4729d956af5e3af8646b0670d/src/service/presence/mod.rs#L158), which may result in (at best) flickering presence, or even (at worse) presence storm. The solution here would likely be to buffer presence changes and apply the same timeout period regardless, or simply drop changes that are too quick, or even just not federate them.
nex added the
Bug
Matrix/Client
Matrix/Federation
Priority
Low
labels 2025-05-15 17:17:17 +00:00
Owner

The original intent was to just eat any updates within the "minimum update period" (seems like 60s, REFRESH_TIMEOUT) that did not change the status or presence value. If the logic on squelching is messed up, addressing that would be faster than a cache.

The original intent was to just eat any updates within the "minimum update period" (seems like 60s, REFRESH_TIMEOUT) that did not change the status or presence value. If the logic on squelching is messed up, addressing that would be faster than a cache.
nex added the
Status
Needs Investigation
label 2025-05-31 00:00:48 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: continuwuation/continuwuity#828
No description provided.