Skip to content

android: resolve LocalAPI backend through Client - #900

Merged
kari-ts merged 1 commit into
mainfrom
kari/client
Oct 23, 2026
Merged

kari-ts merged 1 commit into
mainfrom
kari/client

Conversation

@kari-ts

@kari-ts kari-ts commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

LocalAPI requests currently rely on a static application reference populated by Request.setApp() during backend initialization. We introduced a lazy init in c56420b to ensure we weren't making LocalAPI calls before initialization, but the property is never accessed, and as a result, requests issued during a cold start can fail before the backend is initialized.

This change has Client provide libtailscale to each request instead of relying on global state, making Client responsible for supplying the dependency rather than requiring requests initialize themselves. When each request executes, we get the current libtailscale application instance (or initialize if necessary).

Fixes tailscale/tailscale#20884

LocalAPI requests currently rely on a static application reference populated by Request.setApp() during backend initialization. We introduced a lazy init in c56420b to ensure we weren't making LocalAPI calls before initialization, but the property is never accessed, and as a result, requests issued during a cold start can fail before the backend is initialized.

This change has Client provide libtailscale to each request instead of relying on global state, making Client responsible for supplying the dependency rather than requiring requests initialize themselves. When each request executes, we get the current libtailscale application instance (or initialize if necessary).

Fixes tailscale/tailscale#20884

Signed-off-by: kari-ts <kari@tailscale.com>

@hiimtmac hiimtmac left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Perhaps in the future we should try and decouple Request from app but that is out of scope of this fix.

@kari-ts
kari-ts merged commit 4aae7d2 into main Oct 23, 2026
4 checks passed
@kari-ts
kari-ts deleted the kari/client branch October 23, 2026 17:55
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.

Android app 1.102.2 crashing again — regression of #14125/#14314 (lateinit property app has not been initialized)

3 participants