Repository navigation
Description
Client or integration
Codex App
Area
Proxy and routing / streaming
Summary
When a MacBook running a Codex task loses its network connection during sleep or a Wi-Fi transition, OpenCodex can return a 502 for an upstream DNS failure. The active task stops and requires a manual continue after connectivity returns.
Could OpenCodex keep an eligible active request waiting and retry once its upstream provider is reachable, allowing the task to continue automatically? Waiting should respect cancellation, avoid retrying requests with uncertain upstream effects, and avoid consuming a short retry budget while offline.
Reproduction
- Run the Codex App with OpenCodex as its local Responses provider.
- Start an active task, close the MacBook and move away from its Wi-Fi network.
- Open the laptop and connect to Wi-Fi again.
- Observe the error below and the stopped task. Sending
continueresumes work.
This is an observed interruption; a controlled reproduction and the precise timing of the network transition have not yet been verified. The screenshot shows a DNS failure through the local proxy, not the complete upstream request history.
Version
OpenCodex 2.93.0 installed at time of report; Codex CLI 0.164.0 installed. The Codex App's bundled runtime version was not verified.
Operating system
macOS 26.7
Provider and model
The failed upstream hostname was chatgpt.com. Model not established from the screenshot.
Error output
unexpected status 502 Bad Gateway: Provider unreachable: getaddrinfo ENOTFOUND chatgpt.com, url: http://127.0.0.1:10100/v1/responses
Additional context
OpenCodex classifies pre-connection reachability errors such as ENOTFOUND, while its Responses handler can return a 502 for an upstream connection failure. Codex has a separate connection-failure retry mechanism (openai/codex#37485); whether the proxy's 502 bypasses that mechanism in this exact scenario needs verification. A connection lost after upstream dispatch or after streaming begins may need different handling because the request's outcome can be uncertain.
Checks
- I searched existing issues and documentation.
- I removed secrets, tokens, account details, request credentials, and personal data.
Activity
lidge-jun commentedon Oct 30, 2026
Maintainer triage (2026-10-30, against
dev3a70dd4788):Current behaviour matches the report.
src/lib/upstream-reachability.tsclassifiesENOTFOUND,EAI_AGAIN,ECONNREFUSEDand Bun'sConnectionRefused(from the error code and a boundedcausechain, never the message) as failures before any connection was made.src/lib/upstream-retry.tsdeliberately does not retry those: its retries cover connection resets proven safe to resend and short backoff after a received transient 5xx. So when the network drops (laptop sleep, Wi-Fi switch), the Responses path returns502 Provider unreachable: …immediately (src/server/responses/passthrough-dispatch.ts,src/server/responses/upstream-error.ts), and the turn depends on whatever retry Codex itself applies to a 5xx.A bounded improvement looks feasible: only when the first send fails with a proven pre-connection error, and there is no evidence the upstream was reached (no earlier response, no reset), probe DNS/TCP reachability of the same host for a short cancellable window without sending the model POST, then resend the original request at most once under the existing physical-attempt budget and admission rules. Implementation notes: the pre-connection classifier should move into a leaf module (reachability already imports the retry helper),
structure/transports/responses-failover.mdneeds the contract, and the regression belongs intests/providers/upstream-transient-retry.test.ts(initialENOTFOUND→ failed probes → recovery → one resend succeeds; plus cancellation, timeout, exhausted budget, DNS error after an earlier 5xx/reset, and failure after the response started).It needs one product decision before anyone builds it: how long a request may wait for the network (the reporter's case suggests tens of seconds, but every second is held against the client's own timeout, auth expiry and concurrent requests), and whether it should be on by default. Keeping this open for that decision; no change lands in this maintenance pass.
Ingwannu commentedon Oct 30, 2026
The report distinguishes a DNS failure from an already-dispatched/streaming interruption correctly. Against dev
3ea89653f5727aea41948ddbd5e833f74afe3e36, the existing transport/retry owner already separates reachability errors from ambiguous upstream resets; a screenshot of a final 502 does not show whether an earlier physical attempt in that logical request sent bytes. Holding an offline request would also need an explicit bounded wait/deadline, cancellation, wake/reconnect, and single-owner retry contract.Please retain a synthetic/redacted attempt trace with selected HTTP/WS transport, exact build, physical send count, transport-owned failure phase and client cancellation/deadline. No request body or account identifiers are needed. A focused proposal should first exercise an initial DNS failure followed by recovery, cancellation while offline, deadline expiry and a prior ambiguous/partial send; the last case must not acquire replay permission. I have not reproduced the laptop transition or changed any running service. Keeping this open; a proxy 502's interaction with the installed client retry path is still unverified.
lidge-jun commentedon Nov 10, 2026
Rechecked on
devdf0e6ccc41: unchanged since the 2026-10-30 triage. A pre-connectionENOTFOUND/EAI_AGAIN/ECONNREFUSEDis still classified insrc/lib/upstream-reachability.tsand still answers502 Provider unreachableimmediately.fetchWithResetRetrydoes not retry it.The design questions from that triage still decide this, so it stays open:
The window length and the default are product choices for the owner. The regression set from the triage (recovery, cancellation, deadline, prior ambiguous send) applies whichever option is chosen.
lidge-jun commentedon Nov 16, 2026
Owner decision (lidge-jun, 2026-11-16): add an opt-in wait (default off): after an offline DNS/connect failure, wait up to N seconds for reachability and resend once, under the existing replay-safety rules.
fix(responses): bound offline DNS probes and restart the slow-attempt…
fix(responses): wait only for DNS failures on a request's first send,…
feat(responses): opt-in offline wait and one resend after a pre-conne…
fix(responses): probe the name the send resolves, the proxy's when on…
pr-assets: #7958 offline resend Logs label
test(responses): pin the executor-classification fixture to direct eg…
fix(responses): keep the offline wait for OpenCodex's own xAI and Mis…
fix(responses): keep the DNS error on a cancelled offline wait and la…
merge upstream/dev into feat/codex-incremental-upload-history-slim