Skip to content

Codex session stays in use after its reader dies, leaving runs stuck until restart #8

Open

Description

@iXab3r

Problem

T3 can keep a Codex session in use after it has stopped reading that session's output. Runs stay running, requests wait with no deadline, and only a T3 restart recovers them.

The confirmed code gap: packages/effect-codex-app-server/src/protocol.ts turns typed reader and writer failures into transport termination, but not defects. client.ts ignores typed handler errors, while adapter notification handlers end in Effect.orDie, so any handler failure reaches the reader as a defect. The reader fiber then dies silently:

  • onTermination is not called, so the adapter and session manager never learn about it.
  • Pending requests are not settled.
  • The session stays registered, and later requests go to a writer that is still alive with no reader behind it.
  • The child's stdin stays open, so the process lives on unread.

The writer has the same gap.

Incident (2026-11-04, UTC)

T3 desktop 0.1.6-nightly.20261103.26 on Windows, Codex 0.166.0, shared app-server session. Several threads showed wrong statuses for over two hours.

Time What happened
15:44:50.207 Last incoming message on the shared session: error with willRetry: false, Fatal error: application network permission was revoked
after that T3 kept writing requests 182-188 and none were answered
15:56:48 Codex starts logging dropping message for disconnected connection: ConnectionId(0) (362 warnings, last at 17:18)
15:58 Last native activity on one affected turn, never seen by T3
18:08:33 Four inspected runs are cancelled only by startup recovery after a restart

The UI kept updating throughout, so this is stale server state, not a rendering problem.

How much of the incident this explains

The defect path is real and reproducible, but it is not proven to be what happened in this incident.

  • The error handler itself is trivial and does not block. No evidence shows which handler, if any, failed.
  • T3 server traces for that window were lost (they start around 18:40), and no Codex stderr or stdout writer logs survive.
  • Codex began dropping messages 12 minutes after the silence. On stdio its stdout writer blocks rather than dropping a slow client, so the connection goes away on a write error. Why that happened at 15:56 is unknown.
  • The host was under Windows resource exhaustion around this time. How that relates to the silence is not established.

Raw logs and thread history stay private and are not attached here.

Steps to reproduce

No live provider or memory pressure is needed:

  1. Start a Codex app-server client on a real child process.
  2. Register a notification handler that dies, as adapter handlers do through Effect.orDie.
  3. Have the process send that notification and then answer a pending request, while staying alive.

Actual: the request never completes, awaitTermination never fires, and the process keeps running with nobody reading it.

Expected: the request fails with a transport error that carries the original cause, later requests are rejected, the adapter event stream fails so the session is released, and the child's stdin closes.

Scope

In scope, and what this issue will fix first:

  • Any abnormal reader or writer exit, including defects, terminates the transport.
  • Normal scope shutdown is not reported as a failure.

Not covered by that fix, and needed before this incident can be called closed:

  • A notification handler that never returns.
  • A channel that stays open but goes silent. This needs a liveness check that does not depend on the blocked reader, and it must not fail a healthy long-running tool call.
  • error with willRetry: false that is never followed by turn/completed.
  • Replacing a lost shared session without duplicating native work that is still running.

Upstream

No upstream PR does exactly this. Nearby work, as of 2026-11-04:

  • pingdotgg/t3code#27924 (merged): typed writer errors only.
  • pingdotgg/t3code#28711 (open, mergeable): decouples stdout reading from notification routing, for issue pingdotgg/t3code#28697. Closest pattern, but a defect in its routing fiber is still uncaught, so this fix would move there if that lands first.
  • pingdotgg/t3code#18764 (open, conflicting): liveness probe. It covers defects and hangs, with detection taking up to about 2 minutes.
  • pingdotgg/t3code#30995 (open): exit status accuracy only.
  • pingdotgg/t3code#14134 (closed): per-request timeouts.

Related issues: pingdotgg/t3code#24300, pingdotgg/t3code#30649.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions