ZhuLinsen/daily_stock_analysis · error · CodexAppServerError
timeout
timeout
Error message
App Server request timed out: {method} What it means
The JSON-RPC request() wrapper gives every call a monotonic deadline (request_timeout capped by the transport deadline). If writing the request frame to the app-server's stdin cannot complete within that deadline, the transport pops the pending request, terminates the process (a timed-out write means the pipe or process is wedged), and re-raises with code 'timeout' naming the failed method.
Source
Thrown at src/agent/codex_app_server_transport.py:347
deadline = min(deadline, self.deadline)
response_queue: queue.Queue = queue.Queue(maxsize=1)
with self._state_lock:
request_id = self._next_id
self._next_id += 1
self._pending[request_id] = response_queue
try:
self._write_message(
{"id": request_id, "method": method, "params": params},
deadline=deadline,
respect_cancellation=respect_cancellation,
)
except CodexAppServerError as exc:
with self._state_lock:
self._pending.pop(request_id, None)
if exc.code in {"cancelled", "timeout"}:
self._terminate_process()
if exc.code == "timeout":
raise CodexAppServerError(
"timeout",
f"App Server request timed out: {method}",
) from exc
if exc.code == "cancelled":
raise CodexAppServerError(
"cancelled",
"App Server request was cancelled",
) from exc
raise
while True:
self._raise_if_fatal()
if (
respect_cancellation
and self.cancel_event is not None
and self.cancel_event.is_set()
):
with self._state_lock:
self._pending.pop(request_id, None)View on GitHub (pinned to 5159bd72e8)
Solutions
- Increase request_timeout (and the overall deadline feeding remaining_timeout()) so each RPC has enough headroom
- Check the budget before each call: skip follow-up calls once remaining_timeout() is below a minimum viable threshold instead of letting them time out
- Investigate why the app-server is not draining stdin: capture its stderr, check CPU/memory, verify the binary version
- After this error the transport is terminated; create a fresh transport/agent session rather than reusing the dead one
Example fix
# before
client.request_timeout = remaining_timeout() # may be 0.05s at end of budget
client.request("turn/start", params)
# after
left = remaining_timeout()
if left < MIN_RPC_BUDGET: # e.g. 5.0
raise TimeoutError(f"insufficient budget for next RPC: {left:.2f}s")
client.request_timeout = left
client.request("turn/start", params) Defensive patterns
Strategy: retry
Validate before calling
left = remaining_timeout()
if left < MIN_RPC_BUDGET:
raise BudgetExhausted(f"{left:.2f}s left, below the {MIN_RPC_BUDGET}s minimum per-RPC budget")
client.request_timeout = left Try / catch
try:
client.request(method, params)
except CodexAppServerError as exc:
if exc.code == "timeout":
client = rebuild_transport() # process was terminated; fresh session required
return retry_once(client, method, params)
raise Prevention
- Budget-check remaining_timeout() before every RPC in the session flow
- Give each RPC a timeout proportional to its real latency (turn/start needs far more than thread/start)
- Log app-server stderr alongside timeouts to distinguish hung process from tight budget
When it happens
Trigger: The Codex App Server process is hung or blocked and not draining stdin; the per-request request_timeout or the overall remaining_timeout() budget (e.g. client.request_timeout = remaining_timeout()) is set too small; the writer lock is held by another stalled request; the process died without the reader noticing.
Common situations: Total turn budget nearly exhausted so remaining_timeout() is a fraction of a second when the next call is made; a slow model turn keeps the app-server busy so it stops reading stdin; OS-level backpressure on a full stdin pipe; concurrent requests serialized behind a stuck one.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- cancelled
- protocol_error
- {call_name} 调用超过 {wait_seconds:g}s,已放弃等待
- [AlphaVantage] HTTP request failed for {symbol}: {e}
- [Finnhub] HTTP request failed for {symbol}: {e}
AI-assisted analysis of ZhuLinsen/daily_stock_analysis@5159bd72e8 (2026-08-15).
Data as JSON: /api/errors/0146186be461ea44.
Report an issue: GitHub.