From 3ca79fd771f1a252d34eca079a6fe53918d04c3d Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Thu, 24 Sep 2026 05:13:15 -0700 Subject: [PATCH] fix: codex app-server crash text reaches the user when stderr lags the exit (#121467) Same race as the ACP client: _subprocess_died reads stderr_tail() the moment is_alive() turns False, before the reader thread has the crash lines, so the user saw 'exited unexpectedly' with no cause (CI on main: test_crash_mid_item...). stderr_tail() now joins the reader briefly once the process has exited. --- agent/transports/codex_app_server.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/agent/transports/codex_app_server.py b/agent/transports/codex_app_server.py index ee39918276..055d0b6aba 100644 --- a/agent/transports/codex_app_server.py +++ b/agent/transports/codex_app_server.py @@ -281,6 +281,9 @@ class CodexAppServerClient: def stderr_tail(self, n: int = 20) -> list[str]: """Return last n lines of codex's stderr (for error reports).""" + if self._proc.poll() is not None: + # The reader can still hold the crash text when the exit is first observed (#121467). + self._stderr_reader.join(timeout=1.0) with self._stderr_lock: return list(self._stderr_lines[-n:])