Skip to content

[Bug]: Remote updates leave the service launcher pinned for good, and a macOS service install from inside the service leaves it unloaded #37705

Open

Description

@Nipsuli

On behalf of user by Claude Opus 5.5 (Claude Code)

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Install the background service with t3 service install (ours was on 0.1.4-nightly.20261028.3824, Oct 28).
  2. Update the server remotely from the app over the next few weeks ("Update everything"), up to 0.1.10-nightly.20261116.4787.
  3. Run t3 service status on the host, and look at the launcher process.

Expected behavior

A host that is only ever updated remotely ends up on a current launcher eventually, or at least the app says the launcher needs a repair.

Actual behavior

On all three of our hosts (two macOS launchd, one Linux systemd user unit), the unit still ran the Oct 28 launcher (0.1.4-nightly.20261028.3824/t3 __service-launcher) as the parent of a 0.1.10 t3 serve. In process monitors this looks like two T3 versions running, with an old one that "refuses to die": killing it does nothing because KeepAlive starts it again. The only sign was Status: needs an update or repair from t3 service status on the host. Nothing in the app showed it.

This is the remaining part of #34502. #34603 fixed the update failure, and its description says a protocol-3 launcher stays protocol 3 until a local t3 update or t3 service install. So far, then, the launcher never updates on a host that nobody opens a shell on.

A launchd handoff is possible. A comment on #34502 suggested that the server could run the staged runtime's service install itself, and noted that launchd has no handoff like systemd-run. We tested that on macOS 26.7.2 with a throwaway launch agent set up like T3's plist (KeepAlive, AbandonProcessGroup=false, ProcessType=Interactive, ExitTimeOut). A process inside the job tried to do what service install does: launchctl bootout --wait the job, point its plist at a new program, launchctl bootstrap it again.

How the install runs from inside the job Result
As a direct child (what bootService.ts does on launchd today) Killed by bootout. The job is left unloaded: the service stays down until the next login.
Double-fork + setsid Survives. The job comes back on the new program.
Separate one-shot job: launchctl bootstrap gui/$UID oneshot.plist (RunAtLoad, LaunchOnlyOnce) Survives. The job comes back on the new program.
Rewrite the plist on disk, then exit and let KeepAlive respawn Respawns the old program: launchd keeps using the definition it loaded.

What follows from this:

  1. A one-shot job bootstrapped into gui/$UID is the launchd equivalent of the systemd-run --user --collect handoff at bootService.ts:1305, which handles only systemd today. It needs a unique label and a bootout of that label afterwards, because LaunchOnlyOnce jobs stay loaded after they exit.
  2. Today, on launchd, runningInsideService doesn't change anything. service install runs manager.stop (L1332–1335), and going by our test, that kills the installer between bootout and bootstrap. That leaves the service unloaded, and on a host reached over SSH, nobody can see that. An agent running in a T3 thread on that host that runs t3 service install would cause this. We reproduced it with a stand-in job, not with T3 itself.
  3. Repointing the plist only takes effect after a real bootout and bootstrap, so "rewrite the unit and let it respawn" isn't enough on macOS.

We did not test the alternative of the launcher execing into the staged launcher in place.

Impact

Major degradation or frequent failure

Version or commit

Server 0.1.10-nightly.20261116.4787, launcher 0.1.4-nightly.20261028.3824, source references at c8c51af

Environment

macOS 26.7.2 and macOS 27.2 (arm64, launchd); Arch Linux / Omarchy, kernel 7.2 (systemd user unit). Updated remotely from the T3 Code app.

Workaround

On each host, run ~/.t3/runtime/versions/<current>/t3 service install. That rewrote the unit and restarted onto the current launcher. On the Linux host it also ended the agent sessions running there, as other commenters on #34502 saw.

Related issues

#34502, #34603, #17225 (each new versioned launcher path on macOS also needs new privacy approvals).

Activity

  1. benwmerritt commented on Nov 24, 2026

    @benwmerritt

    Another real-world hit of this on Linux (systemd user unit), with the knock-on race from #24225.

    Versions

    • Server: 0.1.12-nightly.20261124.5178, self-updating to 5191
    • Service launcher (unit ExecStart): 0.1.7-nightly.20261031.4004, pinned since Oct 31 because every update since was a self/remote update
    • Desktop app connected over SSH: 0.1.12-nightly 5111

    What happened (ACDT)

    • 03:28:10: server prepares the update and hands off to the launcher, writing desktop-update-in-progress with a 60s TTL.
    • 03:29:10: marker expires while the old launcher is still in its pre-update DB backup.
    • 03:29:16: the SSH reconnect finds nothing owning the home (the 4004 launcher has no service-serving.lock support) and starts its own t3 serve (5111) on :3773, which warns the DB migration history diverges (108–111 unknown).
    • 03:29:20: the 5191 child fails with ServerAlreadyRunningError; the launcher logs "Another T3 Code server owns this T3 home. Stop it, then restart this service." and goes idle. service-state records status: failed, reason: state-dir-owned. The older SSH-started server kept serving outside systemd until a manual restart 37 min later; the update was never retried.
    INFO Server update prepared; handing off to the service launcher. {targetVersion: 0.1.12-nightly.20261124.5191}
    [ssh server] Database migration history diverges from this build ... 108..111 unknown to this build
    [ssh server] Listening on http://127.0.0.1:3773
    ERROR ServerAlreadyRunningError: A T3 Code server already owns ~/.t3/userdata ...
    [service-launcher] Another T3 Code server owns this T3 home. Stop it, then restart this service.
    service-state.json: update {target 5191, status failed, reason state-dir-owned}
    

    The same ServerAlreadyRunningError handoff failure appears at least 3 earlier times in this host's boot-service.log, so it recurs whenever an update collides with an SSH reconnect.

    Suggested fixes

    1. For this issue: on systemd, after a committed update, run the staged runtime's service install through the existing systemd-run --user --collect handoff so the launcher stops being pinned.
    2. While a pre-serving-lock launcher is in charge, keep the update marker fresh until the new child owns the home, or size the TTL to cover the DB backup.
    3. The SSH launch should refuse to start a server whose build doesn't know the DB's migration history.

    Workaround: running t3 update -y locally on the host updated to 5191 and repointed ExecStart to the 5191 launcher in one step; service-serving.lock is now held and SSH reconnects attach to the service server. t3 service install would also work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions