Repository navigation
fix(responses): keep the DNS error on a cancelled offline wait and label the resend (#7958) - #8833
Conversation
…bel the resend (#7958) A client cancel during the opt-in offline wait made the waiter reject with the abort reason, so fetchWithResetRetry surfaced AbortError instead of the original ENOTFOUND/EAI_AGAIN. On Codex pool sends classifyTransportFailureKind then charged the account (connect_error) for a host-wide failure (connect_neutral). The waiter now answers false on cancellation, during a probe, between probes, or after a late DNS answer, and fetchWithResetRetry rethrows the original error. The single resend after the wait was reported as "connection-reset". It now carries its own recovery kind, "offline-resend" (cause transport-unsent), through UpstreamSendRecovery, the attempt roster, the failure model and a localized Logs label in all 11 locales and the classic dashboard. It keeps the keep-alive opt-out: sockets pooled before the outage belong to the network that went away. Refs #7958
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
✅ Deterministic PR hygiene checks passed. |
|
Brought current with dev as merge commit ab904a9 (no force-push) after #8832 merged. The only conflict was the import block of |
|
@coderabbitai review |
|
@codex review |
Action not completed
|
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Maintainer integration of #8833 at ab904a9 (Refs #7958). These are the two Low items left from #8790's review, and the final follow-up for the opt-in offline wait.
|
Summary
Refs #7958. This follow-up fixes the two Low review items left on the opt-in offline wait (
offlineResendWaitSec). The DNS-only probe design (ENOTFOUND/EAI_AGAIN, proxy-aware since #8831) is unchanged.1. Cancelling during the wait now returns the original error. The waiter used to call
signal.throwIfAborted()andabortableDelay, so a client cancel during the wait surfacedAbortErrorinstead of the pre-connect DNS error. On Codex forward-pool sends,classifyTransportFailureKind(passthrough-dispatch) then counted that host-wideconnect_neutralfailure as account-attributedconnect_error. Now the waiter insrc/lib/offline-resend.tsanswersfalsewhen the signal aborts at the loop check, during a probe (the expiry race treats a rejection as the end of the wait), between probes, or after a DNS answer that lands once the client has gone.fetchWithResetRetryalso refuses to resend when the signal is aborted after the waiter answers, so it rethrows the original error. The existingif (opts.abortSignal?.aborted) throw err;paths are unchanged. This makes the existing docs row ("a cancelled request returns the original error") true.2. The resend has its own recovery kind.
fetchWithResetRetrypassed"connection-reset"for every send after the first, so the offline resend was logged as a connection-reset recovery. It now reports"offline-resend". A later reset retry in the same leg still reports"connection-reset". The new kind is inUpstreamSendRecovery, theATTEMPT_RECOVERY_KIND_ROSTER(soAttemptRecoveryKind, usage-log read-back and telemetry), andRECOVERY_KIND_CAUSEastransport-unsent(the contract's "bytes provably never reached the origin… DNS failure"; request metrics therefore project it toconnection). The GUI Logs label map covers bothgui/srcandgui/classic, andlogs.detail.attempt.recovery.offlineResendis translated in all 11 locales.Keep-alive decision: the offline resend still opts out (
keepalive: false+Connection: closeinapplyUpstreamRecoveryInit). The wait follows a DNS outage, typically a sleep or a Wi-Fi change, so any socket still pooled for that origin or proxy was opened on the network that went away. Reusing one fails after the body may have left, which turns a provably unsent request into an ambiguous pre-header reset; for a non-replay-safe send that becomes the replay refusal instead of an answer. The resend needs a fresh connection anyway, so the only cost is one handshake. This keeps the old wire behaviour; only the label changes.Neither
src/server/responses/adapter-dispatch.tsnorpassthrough-dispatch.tsis touched.structure/transports/timeouts.mddocuments both behaviours.Failing before / passing after (
tests/responses/responses-offline-resend.test.ts, the same file run againstorigin/dev3ef14ad sources and then this branch: 7 fail / 16 pass → 23 pass / 0 fail):origin/dev)DOMExceptionAbortErrorclassifyTransportFailureKindon the rejectionconnect_error)connect_neutralfetchWithResetRetryrecoveries for offline resend → reset retry[undefined, "connection-reset", "connection-reset"][undefined, "offline-resend", "connection-reset"]; causetransport-unsent; keep-alive opted outlogCtx.activeAttempt.recoveryKinds["connection-reset"]["offline-resend"], resendkeepalive: false["connection-reset"]["offline-resend"], resendkeepalive: falseThe forward-pool classification is checked at the existing
classifyTransportFailureKindseam, using the rejectionfetchWithTransientRetryproduces (the call passthrough-dispatch makes). No case drives a full Codex pool account throughhandleResponses.Verification
The Mac was under heavy load, so tests ran only as focused single files under
/usr/bin/lockf -k /tmp/ocx-test.lock:bun test tests/responses/responses-offline-resend.test.ts: 23 pass / 0 fail. Againstorigin/devsources: 7 fail, as in the table.tests/lib/failure-stage-model.test.ts16 pass,tests/lib/failure-attribution.test.ts16 pass,tests/usage/request-outcome-agreement.test.ts24 pass,tests/lib/ambiguous-resend-gate.test.ts10 pass.gui/tests/locale-parity.test.ts5 pass,gui/tests/i18n-locales.test.ts15 pass.bun run typecheckclean (2,554 files);guitsc -p tsconfig.app.json --noEmitclean;bun run lint:guiclean;bun run structure:checkpassed;bun run privacy:scanpassed.startServeron a scratchOPENCODEX_HOMEwithofflineResendWaitSec: 30, where the provider host's first send failed ENOTFOUND, answered 200 after one resend. The persistedusage.jsonlrow carried"sendCount":2and"recoveryKinds":["offline-resend"]. The dashboard (Vite dev against that server) renders the attempt as below:NOT RUN: full
bun run test(host load; left toci:full),bun run build:gui. The classic dashboard has no tsc project, so its one-line map entry is covered only by the CI build. Windows/macOS lanes were not run (no workflow dispatched).Checklist
Summary by CodeRabbit
New Features
Bug Fixes