fix(infra): treat undici terminated aborts as transient#31860
fix(infra): treat undici terminated aborts as transient#31860liuxiaopai-ai wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 28d93597a4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
| return true; | ||
| } | ||
| const causeMessage = getErrorMessage(cause).toLowerCase(); | ||
| if (causeMessage.includes("aborted") || causeMessage.includes("terminated")) { |
There was a problem hiding this comment.
Tighten cause-message heuristic for terminated errors
The new isUndiciTerminatedFetchError path treats TypeError("terminated") as transient whenever cause.message contains "aborted" or "terminated", even without undici-specific evidence. That over-matches non-network failures (for example, an app-level TypeError("terminated") caused by a business-rule cancellation message), which then makes installUnhandledRejectionHandler suppress process exit for a genuinely unhandled runtime error. Please limit this fallback to stronger undici indicators (stack markers, AbortError, or UND_ERR_* codes) instead of generic message substrings.
Useful? React with 👍 / 👎.
Greptile SummaryThis PR addresses a bug where the gateway could crash on undici Confidence Score: 4/5
Last reviewed commit: 28d9359 |
Summary
Describe the problem and fix in 2–5 bullets:
TypeError: terminatedfromFetch.onAborted.TypeError("terminated")(stack/cause-aware) and classify it as transient network error.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
TypeError: terminatedabort/disconnect rejections; it logs as non-fatal transient network error and continues running.Security Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation:Repro + Verification
Environment
Steps
installUnhandledRejectionHandlerwith an unhandled rejection reason matching undici abort shape:TypeError("terminated")withFetch.onAbortedstack.Expected
Actual
Evidence
Attach at least one:
pnpm test src/infra/unhandled-rejections.test.ts src/infra/unhandled-rejections.fatal-detection.test.tsTypeError: terminatedand fatal-detector non-exit behaviorHuman Verification (required)
What you personally verified (not just CI), and how:
isTransientNetworkErrorreturns true for undiciTypeError: terminatedwithFetch.onAbortedstack.TypeError: terminatedwithout undici/abort context remains non-transient.installUnhandledRejectionHandlerdoes not exit for undici-terminated transient case.TypeError: fetch failedand nested-cause transient paths still pass.Compatibility / Migration
Yes)No)No)Failure Recovery (if this breaks)
28d93597a.src/infra/unhandled-rejections.tssrc/infra/unhandled-rejections.test.tssrc/infra/unhandled-rejections.fatal-detection.test.tsTypeError: terminatederrors (guarded by stack/cause checks).Risks and Mitigations
List only real risks for this PR. Add/remove entries as needed. If none, write
None.TypeError: terminatedas transient.TypeError: terminated.