Skip to content

android: fix exit-node intent worker completion - #848

Open
zs311521 wants to merge 1 commit into
tailscale:mainfrom
zs311521:fix/use-exit-node-worker-structured-concurrency
Open

android: fix exit-node intent worker completion#848
zs311521 wants to merge 1 commit into
tailscale:mainfrom
zs311521:fix/use-exit-node-worker-structured-concurrency

Conversation

@zs311521

@zs311521 zs311521 commented Sep 1, 2026

Copy link
Copy Markdown

Summary

  • await the editPrefs callback inside the worker-owned coroutine scope
  • bound the LocalAPI edit and verify the returned exit-node preferences
  • add focused tests for completion, failure, timeout, cancellation, duplicate callbacks, preference masks, and returned-state mismatch

Problem

UseExitNodeWorker creates a detached CoroutineScope(Dispatchers.Default + Job()), starts editPrefs, and then joins the root Job. A standalone root Job does not complete when its children finish, and nothing explicitly completes it. The non-completing worker can be stopped or rescheduled by WorkManager, consistent with the delayed preference replays reported in tailscale/tailscale#17960.

This change bridges the one-shot callback with structured cancellation, keeps the LocalAPI request under the worker lifecycle, applies a 35-second bound over the existing 30-second LocalAPI timeout, and reports success only when the returned effective exit-node ID and LAN setting match the request.

Cancellation prevents late callback completion but cannot undo a preferences PATCH already accepted by the backend.

Testing

  • make fmt-check
  • make test
  • make go-test
  • ./tool/go mod tidy with a clean diff
  • make tailscale-debug.apk

Related work

Fixes tailscale/tailscale#12720.
Fixes tailscale/tailscale#17960.

PR #793 also changes this worker as part of a broader Android 11 foreground-work change. This PR isolates the callback lifecycle correction and its regression tests. It does not add receiver cached-state shortcuts or foreground notifications.

PR #810 addresses a separate cold-start LocalAPI initialization crash. This change does not modify cold-start initialization.

@zs311521
zs311521 force-pushed the fix/use-exit-node-worker-structured-concurrency branch from 870a8a5 to 0af5732 Compare September 1, 2026 02:50
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.

Exit node intents unreliable with Tasker on Android version of app Intent USE_EXIT_NODE not working

1 participant