Repository navigation
fix: use the agent-device proxy lease for remote devices - #1029
Merged
Merged
Conversation
The generated remote profile had no lease provider, so agent-device applied its 60 s default lease, which is not renewed while install uploads the artifact. A 449 MB APK then failed the install with Lease is not active. The profile now sets leaseProvider proxy and the clientId proxy admission requires, which gives a 5 minute lease for both remote backends. Refs #924
janicduplessis
force-pushed
the
fix/924-eas-lease-retry
branch
from
September 24, 2026 16:26
f847917 to
1f7007f
Compare
Collaborator
Author
|
Real
The exact Not covered: the Windows-host item of #924, so this PR still says |
janicduplessis
marked this pull request as ready for review
September 24, 2026 20:06
This was referenced Sep 25, 2026
Closed
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.
Description
stim android --remote easwith a 449 MB debug APK failed at install withUNAUTHORIZED: Lease is not active(#924). agent-device heartbeats or allocates the lease once, when a command starts, and does not renew it whileinstalluploads the artifact. Stim's generated remote profile set noleaseProvider, so agent-device used its default policy. Under that policy the client sends no TTL and the daemon applies its 60 s default (lease-registry-scope.ts). The upload took 1m47s, so the install RPC always arrived after the lease had expired. The profile is shared by--remote proxyand--remote eason both platforms.Solution
The profile now sets
leaseProvider: 'proxy', which selects agent-device's proxy lease policy with a 5-minute TTL (connection-runtime.ts; the daemon also defaults proxy scopes to 300 s, lease-scope.ts). This is the same shape agent-device's ownconnect proxywrites (proxy-profile.ts). A proxyopenrequiresleaseId,tenantId,runId,clientIdanddeviceKey(request-admission.ts). The profile addsclientId, set to the per-workspace scope that tenant and runId already use.installandopenare proxy lease-allocating commands and resolvedeviceKeyfrom the daemon's device list for the profile platform.connectandcloseare lease-deferred, andalert acceptreuses the lease persisted by the earlier install and open.The upload is still not renewed, so an upload longer than about 5 minutes (roughly 1.2 GB at the 4 MB/s seen in #923) would still fail. I did not add a retry. A retry would allocate a new lease and upload again, because the daemon's upload preflight never reports a cache hit.
The proxy lease pins a
deviceKey. On a self-hosted--remote proxydaemon shared by several workspaces, a second workspace that targets the same device can get a device-lease-busy error for up to 5 minutes, until the holder runsstim stopor the TTL lapses. Before this change that window was 60 s. EAS is unaffected, because each session has its own daemon.Verified from source, at agent-device main
efce352and at v0.20.10, the version installed here: the policy selection, the 5-minute proxy TTL, the lease-deferred and proxy-allocating command sets, and that the profile schema acceptsleaseProviderandclientId. The daemon's required-but-unavailable provider gate cannot refuseproxy, becauseproxyis not inDEFAULT_PROVIDER_RUNTIME_REQUIRED_IDSat either version (provider-device-runtimes.ts).The remaining unverified risk is an EAS daemon configured with
maxLeaseTtlMsbelow 300000. Allocation would then fail withINVALID_ARGS Lease ttlMs must be between ...(lease-registry-scope.ts). A proxy daemon with several devices for the profile platform fails device selection withAMBIGUOUS_MATCH, as it already does today, so that is not a regression. The real--remote easrun is still open on #924, together with the upstream issue.Test plan
agent-device.test.ts: the generated profile carriesleaseProvider: 'proxy'andclientId. Without them, agent-device falls back to the 60 s default lease.stim android --remote eas --eas-profile developmentfrom a Windows host with the trailhead debug build: pending (EAS cost). Expect install and launch to succeed and the agent-device diagnostics to showlease_allocatewithttlMs: 300000.Refs #924