Fix: forced re-login on cold start when radiance core not yet ready#8914
Fix: forced re-login on cold start when radiance core not yet ready#8914david-lant wants to merge 1 commit into
Conversation
Auto-diagnosed from Freshdesk ticket #180375. Root cause: HomeNotifier.build() calls getUserData() before the async SetupRadiance has stored the core, so it returns "radiance not initialized", build() throws with no fallback, and the persisted session is never restored — forcing a manual re-login on every launch (reliably in China where GFW-blocked config/auth traffic delays init). Retry the local read while the core is still initializing instead of failing permanently. Co-Authored-By: Claude <noreply@anthropic.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
I don't think bounded polling is the right fix here. The 5-second retry window can still lose the race if post-upgrade setup takes longer, and matching #8915 fixes the ordering at the source: Android exposes a replayable readiness signal after I suggest closing this in favor of #8915. |
Summary
Auto-fix for Freshdesk ticket #180375.
Chinese Android Pro user on v9.1.15 beta (China Mobile) reports that after upgrading, the app forces a fresh login on every launch — the cached session is never restored.
Root cause: On cold start,
HomeNotifier.build()callsgetUserData()before the asynchronously-startedSetupRadiancehas stored the Go core.Mobile.userData()returnsradiance not initialized, sobuild()throws with no fallback and the persisted logged-in/Pro session is never restored (checkIfUserProAndDeviceIsAddednever runs). The stored setting still readsuserLoggedIn: true, yet the app looks logged-out. Reliably reproduced in China, where GFW-blocked config/auth traffic (df.iantem.ioreset) widens the init window so the race is lost on every launch. Confirmed against logs: 9.1.9/9.1.11 launches on the same device succeed; the first 9.1.15 launch onward throwsradiance not initializedatgetUserData.What changed:
lib/features/home/provider/home_notifier.dart—build()now retries the localgetUserData()read a bounded number of times (10 x 500ms) only while the failure is the transient "core not initialized" race, restoring the session once radiance comes up. Any other failure surfaces immediately with the original throw behaviour, so genuine errors are unchanged.Test plan
df.iantem.io) — verify the session is restored instead of showing logged-outrefreshUser/fetchUserData(unchanged, but same provider)Notes for reviewer
This is a Dart-side mitigation of a startup ordering race. A more complete fix would have
SetupRadiancesignal readiness sobuild()canawaitit rather than poll; that's a larger change spanning the platform channel and is left for follow-up. See ticket diagnosis for the full call path and the unresolved question of which radiance bump between 9.1.11 and 9.1.13 widened the window.Auto-generated by
/ticket-autodiagnose->/issue-fix.