[expo] Android: useAuth().isLoaded never resolves on cold start when Wi-Fi already connected (native connectivity monitor hang)
@wobsoriano đang làm issue này rồi.
Từ ngày 23/6/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Summary
On a real Android device, @clerk/expo's useAuth().isLoaded never becomes true on a cold start when the device is already connected to Wi‑Fi, so any gate like if (!isLoaded) return <Spinner/> spins forever. The device network is completely healthy. Toggling Wi‑Fi off/on while it's stuck immediately unblocks it and the app proceeds. It does not reproduce on the Android emulator (its network state flickers during boot), which makes it easy to miss in QA but it hits real users.
This looks like the native clerk-android connectivity monitor waiting for a ConnectivityManager onAvailable callback that never fires for a network that was already available before the callback was registered (i.e. every normal cold start on stable Wi‑Fi).
Environment
@clerk/expo |
3.5.2 (also repro'd intent on 3.4.3; canary 3.5.3 unchanged) |
| native | com.clerk:clerk-android-api / -ui 1.0.28 (also 1.0.30) |
| Expo SDK | 56 (New Architecture / bridgeless, React 19, RN 0.85.3) |
| Device | Samsung Galaxy Z Fold 3 (SM‑F926B), real device, stable Wi‑Fi |
| Clerk instance | development (pk_test_…) |
| Build | EAS preview (release-style standalone) |
Steps to reproduce
@clerk/expowith a standard<ClerkProvider publishableKey tokenCache>and anisLoadedgate (e.g. expo-router group layout returns a spinner while!isLoaded).- Build a release/standalone Android build, install on a real device on stable Wi‑Fi.
- Cold-launch the app (let Wi‑Fi settle first; don't toggle anything).
Actual: stuck on the loading state forever; isLoaded stays false.
Expected: isLoaded resolves (network is reachable) and the app proceeds, as it does on web/emulator.
Workaround that proves the cause: while stuck, toggle Wi‑Fi (or airplane mode) off→on. isLoaded resolves within ~1s and the app proceeds. Verified via adb shell svc wifi disable && svc wifi enable.
Evidence the network is fine
From the same device, while the app is hung:
# DNS + HTTPS to the Frontend API, x3
$ adb shell curl -s -m 12 -o /dev/null -w '%{http_code} %{time_total}s' \
'https://<instance>.clerk.accounts.dev/v1/environment?_clerk_js_version=5'
200 1.07s
200 0.62s
200 0.62s
DNS resolves, TLS connects, ping to the Clerk CDN ~7ms, Private DNS off, device clock correct.
Relevant logcat (cold start, app pid)
ReactNativeJS: Running "main"
ReactNativeJS: Clerk: Clerk has been loaded with development keys...
ConnectivityManager: registerNetworkCallback(...)
com.clerk.api.configuration.connectivity.NetworkConnectivityMonitor.configure(...)
com.clerk.api.configuration.ConfigurationManager.configure(...)
com.clerk.api.Clerk.initialize(...)
expo.modules.clerk.ClerkExpoModule$configure$1.invokeSuspend(ClerkExpoModule.kt:124)
…then nothing further — init never completes, so isLoaded never flips. After a Wi‑Fi toggle, init completes and the sign-in screen renders.
Things we tried (that did NOT fix it)
__experimental_resourceCache(offline-support): no change on a clean install — it only helps once a successful load has seeded the cache, but the initial load is exactly what hangs, so the cache never seeds.- Excluding the native module to run JS-only (
expo.autolinking.android.exclude: ["@clerk/expo"]): crashes withError: Cannot find native module 'ClerkExpo'becausedist/specs/NativeClerkModule.android.jscallsrequireNativeModule("ClerkExpo")at module-eval (top level, no try/catch), so importing@clerk/expothrows when the native module is absent. (Separately: a top-levelrequireNativeModulewith no graceful fallback seems risky.) - Upgrading to canary
3.5.3/ native1.0.30— sameclerk-android1.0.28-era connectivity code, no change.
Likely root cause / suggested fix
The native connectivity monitor appears to gate initialization on a network‑availability event rather than reading the current network synchronously. On a cold start where the network is already connected, registerNetworkCallback's onAvailable may not fire (it fires for networks that become available after registration), so init waits indefinitely. Reading the active network at registration time (e.g. ConnectivityManager.getActiveNetwork() / registerDefaultNetworkCallback, or seeding the initial online state) — and/or adding a timeout so init resolves even if the monitor never reports — would fix the cold-start hang.
Happy to provide a minimal repro or more logs. Thanks!
- Ngôn ngữ chính
- TypeScript
- Star
- 1.8k
- Fork
- 472
- Merge trung bình
- 2 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 215
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của clerk/javascript
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
clerk/javascript#9611 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
clerk/javascript#9573 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 64/100
clerk/javascript#9775 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
clerk/javascript#9770 · 3 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
clerk/javascript#9667 · 1 bình luận ·
Tất cả issue của clerk/javascript
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
bug v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
modelcontextprotocol/inspector#2458 · 1 bình luận ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
railmapgen/rmp-gallery#4068 ·
-
Mend: dependency security vulnerability status: needs triage 🕵️♀️
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
carbon-design-system/ibm-products#9907 ·