mirror of
https://github.com/wger-project/flutter.git
synced 2026-11-28 17:08:29 +01:00
A rejected refresh token runs clearSessionOnly inside the single-flight refresh future. PowerSync's disconnect can block on an in-flight sync fetch that is itself awaiting that same refresh future through AuthHttpClient's pre-emptive refresh, closing a three-party cycle (refresh -> disconnect -> sync fetch -> refresh) that permanently wedges every authenticated request behind the never-completing refresh. The session-expired message never appears because it is sequenced after the hanging call, and an app restart re-triggers the same rejected refresh during startup revalidation, so the deadlock re-forms immediately. On the keep-data path the DB is not wiped, so there is no re-attach race to guard against; the disconnect is only a courtesy stop of the sync loop and is now fire-and-forget. The wipe path (explicit logout) keeps its ordering. The disconnect hook is injectable for tests because PowerSyncDatabase is a base class that cannot be faked.