Skip to content

[Bug]: Since #44095, OpenCode's server outlives a killed t3 serve and the service stop waits out TimeoutStopSec #45905

Done

Description

@nkoynov

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. Linux, T3 as the systemd user service (t3 __service-launcher), with an OpenCode 2 thread active, so T3 has started its own opencode serve.
  2. A stop where t3 serve doesn't finish its shutdown within the service launcher's 5 s grace and gets SIGKILLed. On our host that is every stop: with "Continue threads after server update" on and a ~25 GB database (about 9,300 threads), prepareForShutdown alone can take over 4 s.
  3. systemctl --user stop t3code (or a restart).

Expected behavior

When t3 serve dies, its OpenCode server goes with it, and the unit stops in a few seconds, as it did up to 0.1.14-nightly.20261127.5319.

Actual behavior

The OpenCode server keeps running after t3 serve is gone. It stays a child of t3 __process-launcher, so that process stays too, and the unit waits for systemd's stop timeout. OpenCode runs in its own t3code-opencode-*.scope, outside the unit's cgroup, so systemd's final SIGKILL doesn't reach it either.

  • 0.1.14-nightly.20261127.5359, 2026-11-29. Stop at 05:03:18 UTC. systemd hit State 'stop-sigterm' timed out after 90 s and SIGKILLed the service launcher (main process) and the process launcher at 05:04:48. The OpenCode server got no signal from T3. Its first SIGTERM came at 05:04:48.46, from our own cleanup script.
  • 0.1.14-nightly.20261128.5413, 2026-11-30. Stop at 05:01:30.33 UTC. The OpenCode server was still running at 05:01:36.43, when our script stopped it. The unit stopped 0.9 s later. There was no timeout only because of our script.
  • 0.1.14-nightly.20261127.5319, 2026-11-28, before the change. The stop took 5.6 s. t3 serve didn't finish its shutdown either (no "shutdown reconciliation completed" line), but no OpenCode server was left behind.

Cause, from the code:

  • Up to 5319, apps/server/src/process/processLauncherWorker.ts SIGKILLed every child's process group and exited when the server's IPC channel closed (process.on("disconnect", …)).
  • refactor(server): launch commands through Effect 4.1.6's proxy process #44095 (0a63dfe, first in 5359) replaced it with Effect's NodeChildProcessProxy. That only installs no-op SIGINT/SIGTERM handlers and has no disconnect handler. So when t3 serve is SIGKILLed, nothing stops the processes it launched.
  • At shutdown, the OpenCode server is stopped only by its own scope finalizer (terminateChild in OpenCodeRuntime.startServerAttempt). The provider layers close after the startup finalizer, which runs prepareForShutdown, providerSessions.shutdown and reconcile("shutdown"). The service launcher SIGKILLs t3 serve after TERMINATE_GRACE_MS = 5_000, so that finalizer never runs.
  • The unit's main process is the service launcher, and it stayed up until systemd's SIGKILL. The process launcher inherits t3 serve's stdout and stderr, which are socket pairs the service launcher reads, so that is likely what keeps it waiting.

The same holds on 0.1.14-nightly.20261130.5465 and main 46f558a.

Impact

Major degradation or frequent failure

Version or commit

0.1.14-nightly.20261127.5359 and 0.1.14-nightly.20261128.5413. Last good: 0.1.14-nightly.20261127.5319.

Environment

NixOS x86_64, systemd 262, T3 as the user service (TimeoutStopSec 90 s, KillMode=mixed), OpenCode 2.4.2 started by T3 in its agent scope. T3 runs with local preloads that patch provider behaviour. None of them touches shutdown, the launchers or process spawning.

Logs or stack traces

# 2026-11-29, 5359 (journalctl --user -u t3code, local time UTC+2)
07:03:18.185 Stopping T3 Code server...
07:04:48.215 t3code.service: State 'stop-sigterm' timed out. Killing.
07:04:48.215 t3code.service: Killing process 1628650 (node-MainThread) with signal SIGKILL.   # t3 __service-launcher
07:04:48.215 t3code.service: Killing process 1628838 (node-MainThread) with signal SIGKILL.   # t3 __process-launcher
07:04:48.228 t3code.service: Failed with result 'timeout'.

# same stop, server trace (span end times, UTC)
05:03:22.991 ProviderRuntimeRecoveryService.prepareForShutdown   4230 ms (getRecoveryThreadIds 4229 ms)
05:03:23.129 last span written

# 2026-11-30, 5413
07:01:30.328 Stopping T3 Code server...
07:01:30.893 t3 serve log: Relay client stopped              (last line)
07:01:36.434 our script: OpenCode server outlived the T3 server that started it, SIGTERM
07:01:37.319 Stopped T3 Code server.

Workaround

A wrapper script around the restart runs systemctl stop in the background. Once t3 serve is gone, it stops the OpenCode servers left under t3 __process-launcher, and the launchers then exit on their own.

Model: Claude Opus 5.5. Harness: OpenCode in T3 Code.

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