Skip to content

Conversation

@gastonfournier
Copy link
Contributor

@gastonfournier gastonfournier commented Oct 16, 2025

Context

Fixes #139
Fixes #140

What’s Changed

  • Added bounded retry with main-thread scheduling for network callback registration, plus an epoch guard so stale retries no-op after close() runs (NetworkStatusHelper).
  • Track callbacks only once registration succeeds; stale callbacks get unregistered immediately if the epoch shifts.
  • close() now clears tracked callbacks, catches redundant unregisterNetworkCallback exceptions, and suppresses security errors so repeated close calls are safe.
  • Tests expanded to cover retry success/failure, cleanup after close, and multiple-close scenarios under the new safeguards.

Testing

  • Manual validation on API 30 emulator:
    • No exception detected but debugged to validate it handles availability and loss of network connection.
    • Manually simulated a SecurityException and verified the retry

Copy link
Member

@chriswk chriswk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable. I say go with it.

@github-project-automation github-project-automation bot moved this from New to Approved PRs in Issues and PRs Oct 16, 2025
@gastonfournier gastonfournier merged commit ebf7c4d into main Oct 16, 2025
2 checks passed
@gastonfournier gastonfournier deleted the fix/network-status-crash branch October 16, 2025 13:12
@github-project-automation github-project-automation bot moved this from Approved PRs to Done in Issues and PRs Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Android 11 ConnectivityManager crash NetworkCallback was already unregistered when calling DefaultUnleash.close()

2 participants