android: harden detached connect timeout gate (refactor branch port of #8696)#8698
Merged
myleshorton merged 1 commit intogarmr/radiance-daemon-refactorfrom Apr 23, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR cherry-picks the main-branch fix from #8696 onto the refactor branch to prevent the Android VPN connectInFlight single-flight gate from getting stuck when the async coroutine is cancelled before its body starts (pre-dispatch cancellation).
Changes:
- Move
connectInFlightreset from anasync { try/finally }block intodeferred.invokeOnCompletion { ... }so the flag clears for all terminalDeferredstates (including immediate cancellation). - Update the surrounding comment to reflect the new reset mechanism and the “early cancellation” wedge scenario.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-pick of #8696 (
8998d94ac) onto the refactor branch.The refactor branch already includes #8689 (
0540dc9ab), which introduced theconnectInFlightsingle-flight gate with thetry { connect() } finally { connectInFlight.set(false) }pattern. That pattern leaves the gate permanently wedged if the coroutine body never starts (pre-dispatch cancellation) — after which every future connect attempt is rejected withIllegalStateExceptionuntil the process is killed.#8696 moves the reset to
deferred.invokeOnCompletion { ... }, which fires on every terminalDeferredstate, including immediate cancellation. Happy path and JNI-still-running timeout path are unchanged.Clean cherry-pick, no conflicts. Diff is identical to what landed on main.
Test plan
🤖 Generated with Claude Code