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.
This commit is contained in:
teknium1
2026-09-24 05:13:15 -07:00
committed by Teknium
parent 51d40c3016
commit 3ca79fd771

View File

@@ -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:])