Skip to content

fix: renew config message TTLs at most once an hour per swarm - #2017

Merged
mpretty-cyro merged 1 commit into
session-foundation:devfrom
mpretty-cyro:fix/config-ttl-extension-cooldown
Sep 29, 2026
Merged

mpretty-cyro merged 1 commit into
session-foundation:devfrom
mpretty-cyro:fix/config-ttl-extension-cooldown

Conversation

@mpretty-cyro

@mpretty-cyro mpretty-cyro commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Every poll asked the swarm to extend the TTL of every active config message. That is a write on every storage node holding those messages, every few seconds, from every client, and service nodes see real disk I/O from it. The extension goes to weeks from now, so doing it once an hour loses nothing.

The change

A poll now skips the config TTL extension for a swarm whose last extension succeeded within the last hour.

  • Per swarm. The user swarm and each group swarm have their own cooldown, so one group's renewal never suppresses another's or the user's own.
  • Success only. A failed extension leaves the cooldown untouched, so the next poll retries it. A failure that started the cooldown would leave the configs un-renewed while looking handled, and repeated failures could let them age out of the swarm.
  • In memory, one hour, constant. No persistence or migration. A restart re-arms it, so the first poll after launch always extends.
  • A throttled poll sends no expire request at all, rather than sending one and ignoring the answer.

Disappearing-message expiry uses a separate path and is unchanged.

Desktop specifics

  • configTtlExtensionThrottle.ts holds a module-level per-swarm map.
  • retrieveNextMessagesNoRetries decides whether to pass configHashesToBump on to buildRetrieveRequest, and records success only when the expire sub-result (last in the batch, when present) returns 200.
  • Timing uses Date.now(), since this is a local interval rather than a comparison with a network value. A clock moved backwards counts as due.

Verification

configTtlExtensionThrottle_test.ts, 6 tests through retrieveNextMessagesNoRetries with BatchRequests.doUnsignedSnodeBatchRequestNoRetries stubbed, counting the batches that actually contain an expire sub-request. Covered: two polls inside the window send one; a poll after the window sends another; a 500 or a rejected batch doesn't start the cooldown; a backwards clock; per-swarm independence. Existing buildRetrieveRequest tests unchanged. tsc clean; prettier and eslint clean on the touched files. Three separate mutations (record regardless of code, drop the gate, drop the backwards-clock guard) each turn the expected tests red.

Same change in the other clients

Every poll asked the swarm to extend the TTL of every active config
message, which is a write on each storage node holding them, every few
seconds, from every client. Service nodes see real disk I/O from it.

The extension is now skipped for a swarm whose last extension succeeded
within the hour. The user swarm and each group swarm are tracked
separately. A failed extension leaves the cooldown untouched so the next
poll retries it. State is in memory only, so the first poll after launch
always extends.

@Bilb Bilb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Bilb Bilb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mpretty-cyro
mpretty-cyro merged commit a41ae82 into session-foundation:dev Sep 29, 2026
11 checks passed
@mpretty-cyro
mpretty-cyro deleted the fix/config-ttl-extension-cooldown branch September 29, 2026 03:10
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