Files
matrix-rust-sdk/crates/matrix-sdk/tests
Ivan Enderlin b01ce21a24 fix(sdk): Remove a cyclic reference of Client in ThreadSubscriptionCatchup.
This patch fixes cyclic reference of `Client` in
`ThreadSubscriptionCatchup`.

`ThreadSubscriptionCatchup` starts a task that call
`thread_subscriptions_catchup_task`. This function captures a clone of
`ThreadSubscriptionCatchup` (why not…) which contains a `WeakClient`,
all good, no cycle here! However, the real task (not the function)
captures `Client` to call `enabled_thread_subscriptions` to know
if the function `thread_subscriptions_catchup_task` must be called.
Consequently, the task captures a clone of `Client`, boom, we have
a cycle.

This patch fixes the problem by spawning the task if and only if
`Client::enabled_thread_subscriptions` returns `Ok(true)`. This check is
done outside the task. It seems saner and avoid creating this cycle.

Consequently, the `ThreadSubscriptionCatchup::new` method becomes
`async`, which is perfectly fine as it was already wrapper inside an
`async` block when initialised by the `Client`.
2026-05-22 11:23:24 +02:00
..