Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@swolfand
Copy link
Collaborator

@swolfand swolfand commented Dec 10, 2025

Summary of changes

This PR integrates Android's ConnectivityManager to enable proactive and automatic reinitialization of the Clerk SDK when internet connectivity is restored.

Previously, if the device was offline during SDK initialization, it would remain uninitialized until a background/foreground app cycle or manual retry. With these changes:

  1. Automatic Connectivity Detection: A new NetworkConnectivityMonitor utility listens for real-time network state changes.
  2. Proactive Reinitialization: When connectivity is regained after being offline, the SDK automatically attempts to reinitialize (if not already initialized) or refreshes client/environment data (if already initialized).
  3. No User Intervention Required: Initialization no longer depends on the user or app performing a background/foreground cycle to detect connectivity changes.
  4. Permissions: Added ACCESS_NETWORK_STATE permission to AndroidManifest.xml.
  5. Tests: Comprehensive unit tests for the NetworkConnectivityMonitor ensure reliable behavior.

Open in Cursor Open in Web

Summary by CodeRabbit

Release Notes

  • New Features

    • Added automatic recovery on connectivity restoration—the app now monitors network changes and intelligently retries initialization or refreshes data when internet connectivity is regained without requiring a restart.
  • Tests

    • Expanded test coverage for network connectivity monitoring.

✏️ Tip: You can customize this high-level summary in your review settings.

Adds NetworkConnectivityMonitor to automatically retry initialization on network restoration.

Co-authored-by: sam <[email protected]>
@cursor
Copy link

cursor bot commented Dec 10, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@swolfand swolfand marked this pull request as ready for review December 10, 2025 18:01
@swolfand swolfand merged commit 65caf03 into main Dec 10, 2025
5 of 6 checks passed
@swolfand swolfand deleted the cursor/connectivity-and-auto-retry-initialization-708b branch December 10, 2025 18:01
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 10, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This change introduces network connectivity monitoring to the Clerk API module. A new singleton utility, NetworkConnectivityMonitor, monitors Android network connectivity state via ConnectivityManager and exposes a StateFlow for real-time connectivity updates. The ConfigurationManager is modified to integrate this monitor, establishing a connectivity-based retry mechanism that triggers automatic reinitialization or data refresh when connectivity is restored after being offline. The ACCESS_NETWORK_STATE permission is added to AndroidManifest.xml to support network state monitoring. A comprehensive test suite validates connectivity state tracking, callback behavior on restoration, and resource cleanup.


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e4dd604 and 724b1db.

📒 Files selected for processing (4)
  • source/api/src/main/AndroidManifest.xml (1 hunks)
  • source/api/src/main/kotlin/com/clerk/api/configuration/ConfigurationManager.kt (3 hunks)
  • source/api/src/main/kotlin/com/clerk/api/configuration/connectivity/NetworkConnectivityMonitor.kt (1 hunks)
  • source/api/src/test/java/com/clerk/api/configuration/connectivity/NetworkConnectivityMonitorTest.kt (1 hunks)

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

3 participants