Skip to content

[Bug]: macOS: t3 service install, t3 service restart and a restarting t3 update run inside T3 have no launchd handoff, so bootout can kill the caller before bootstrap #28552

Open

Description

@tiziano-contorno

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. macOS with the background service installed as the LaunchAgent com.t3tools.t3code.service.
  2. Inside T3 Code on that Mac (a T3 terminal, or an agent's shell tool), run one of:
    • t3 service install with a CLI that differs from the installed launcher;
    • t3 service restart;
    • t3 update when it restarts the service.

Expected behavior

The same as on systemd since #14361: the work is handed to the service manager and completes after the caller dies. Failing that, the command refuses before stopping anything and says to run it from a terminal outside T3.

Actual behavior

From reading the code at v0.1.6. I have not run it on macOS, because the expected result is a stopped service.

  • install() hands off only when manager.kind === "systemd" (bootService.ts L786). On launchd it falls through to runSteps(manager.stop) (L808-L809), which is launchctl bootout --wait gui/<uid>/com.t3tools.t3code.service. launchctl bootstrap runs only after that returns (L860).
  • The launchd manager defines no handoff steps (L288-L354), so restart() also runs stop, then activate (L887-L892).
  • A caller started inside T3 is a descendant of the job. During bootout --wait the server stops its sessions and terminals as it shuts down, and when the launcher exits launchd kills whatever is left in the job's process group, since the plist does not set AbandonProcessGroup (L144). So the caller should die before bootstrap, as it did on systemd in [Bug]: t3 update run from inside T3 (terminal or agent) stops the background service and never starts it #16374. A booted-out job is not restarted by KeepAlive, so the service stays down until the next login or a manual launchctl bootstrap, and remote clients lose the environment.
  • Detection does not match on macOS either. The plist sets T3_BOOT_SERVICE_UNIT=com.t3tools.t3code.service.plist (L162-L163), while runningInsideService compares the variable with t3code.service (L35-L36, L538-L540). An agent process running inside the 0.1.6 service on macOS has T3_BOOT_SERVICE_UNIT=com.t3tools.t3code.service.plist in its environment, so runningInsideService is false there even before the systemd check.
  • The comment in t3 update says "Inside the service it hands off to the target CLI, so stopping this process cannot interrupt the switch" (cli/update.ts L479-L480). That holds only on systemd.

#14361 fixed #16374 for systemd only; its description reports that no macOS/launchd run was performed. This is not #11995: there, on macOS 15, bootout --wait is a usage error, so the stop never runs and bootstrap fails with EIO while the old service keeps running. On this macOS launchctl help bootout lists --wait, so the stop does run. #26088 (open) makes the launchd stop work on macOS 15 as well, without adding a handoff, so it would make this case reachable there too. Agents inside T3 are a likely caller: t3 service status tells them "Run t3 service install to repair it." after a remote update (#17490).

Impact

Major degradation or frequent failure

Version or commit

v0.1.6 (2359643). The same checks are on main @ ce9e016.

Environment

macOS 27.0.1 (arm64); T3 Code desktop 0.1.6; server 0.1.6, under a LaunchAgent installed by an older stable CLI and updated remotely since.

Suggested fix

  • Recognise the launchd marker as well, for example by comparing with the manager's own marker value.
  • On launchd, hand the same work to a separate one-shot launchd job outside the service's job: a temporary plist with its own label and no KeepAlive. (launchctl submit does not fit, because launchd keeps a submitted program alive after a failure.) It would run the target CLI's service install --base-dir …, or the restart, in the same stop-first order and append its output to boot-service.log.
  • At minimum, refuse inside the service on launchd before stopping anything, and say to run the command from a terminal outside T3.

Workaround

Run these commands from Terminal.app or another terminal that T3 did not start.

Activity

  1. PhucHoangHo commented on Nov 20, 2026

    @PhucHoangHo

    Our pinned-source assessment found the same Mac case, and it still reproduces on v0.1.11. From inside the service, t3 update and t3 service install/restart reach the launchd stop (bootout) on their own job before bootstrap. The in-service check matches t3code.service and the Windows task file, but not the launchd plist marker, and the launchd manager has no handoff, unlike systemd and schtasks.

    #28565's launchd handoff looks like it covers this. We also prepared a smaller refusal-before-effects guard that preserves managed-launcher or external-owner maintenance. Would that be useful as a stopgap, or is #28565 the preferred path?

  2. ethanjnrg commented on Nov 20, 2026

    @ethanjnrg

    I hit this on an Apple Silicon Mac Studio running macOS 27.2.1 while updating the T3 background service from 0.1.5 to Nightly 0.1.12-nightly.20261120.5009.

    • At 4:08:13 p.m. local time, launchd logged that a descendant of the T3 service initiated bootout for com.t3tools.t3code.service.
    • The desktop update finished at 4:12 p.m. After that, launchd repeatedly reported that the service job was missing.
    • I used Codex outside T3 to start the service again. It was listening at 4:13:52 p.m., about 5 minutes 40 seconds after shutdown. The updated service responded locally and successfully listed a saved one-time scheduled task.

    I expected the service to come back automatically after the update. The logs show where the stop was initiated, but I couldn't verify the exact command that triggered it.

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