Repository navigation
Conversation
In proxy mode the daemon ends a closed session's lease itself, so a host fronting the daemon never saw a release, and the CLI kept the stale lease id: the next open heartbeated it, got LEASE_NOT_FOUND and reallocated. After a successful close the CLI now sends lease_release for its stored proxy lease (any failure is ignored) and drops the lease from its local connection state. Leases the daemon retains on close, host-allocated macos-app leases and non-proxy connections are left alone.
Size Report
Startup median (7 runs, lower is better):
|
|
|
The code needs a design decision and live evidence before it is ready to merge. At 6e8d5d1 I found no blocking defect, but the daemon should own the lease outcome instead of a cached CLI flag. I did not re-run the live relay run or the tests, and the live claim comes from the PR body. Smoke Tests is still queued, not failing, and there are no conflicts that I know of. The diff touches the top-level CLI close route that smoke flows run, but for local close Could the daemon's close success response ( Not blocking, and you can take or leave these: the skip decision at https://github.com/callstack/agent-device/blob/6e8d5d1/src/cli/commands/connection.ts#L356 reads a CLI-side copy of retain state from the last heartbeat, while the daemon decides at close time, so a stale copy can end a lease the daemon just retained. The hook at https://github.com/callstack/agent-device/blob/6e8d5d1/src/cli.ts#L188 keys on the top-level command name, so batch and failed-close paths skip the release and the local clear. The bare catch at https://github.com/callstack/agent-device/blob/6e8d5d1/src/cli/commands/connection.ts#L360 swallows auth and network errors with no diagnostic, so a diagnostic with the normalized error code would help. #3479 edits Before merge, we need a maintainer decision on whether the close response should own the lease outcome, and Smoke Tests needs to finish. |
Summary
In proxy mode the daemon ends a session's lease on
close, but no release goes over the wire, so a gateway in front of the daemon never learns the lease ended. The CLI also kept the old lease id, so the nextopenheartbeated it, gotLEASE_NOT_FOUND, and allocated a new lease.Now, after a successful proxy
close, the CLI sendslease_releasefor its stored lease and removes the lease from its local connection state. A failed or "not found" release does not failclose. Nothing changes for leases the daemon keeps on close (retainOnClose, now recorded from allocate/heartbeat), host-allocatedmacos-appleases, non-proxy connections, or local mode. 6 files; the remote-proxy docs gain one sentence.Validation
Tested commit
6e8d5d128:pnpm check:affected --runpassed (format, lint, typecheck, layering, fallow, build, docs; 44 related test files, 441 tests).New tests in
cli-close.test.ts. The two release tests fail without the fix. The retain,macos-app, and non-proxy tests each fail when their guard is removed.Live run: built CLI → logging relay →
agent-device proxy→ local daemon, using a private iOS simulator:On
origin/mainthe same flow sends no release afterclose, and the nextopengetslease.heartbeat → 401 LEASE_NOT_FOUNDand then allocates again.With the change,
disconnecton an open session still sendsclosethenlease.release. Local-modeopen/closeworks as before.