Skip to content

fix(infra): prevent gateway exit on wrapped transient DNS/network errors#24582

Merged
steipete merged 1 commit into
openclaw:mainfrom
dorukardahan:codex/fix-dns-unhandled-rejection
Feb 23, 2026
Merged

fix(infra): prevent gateway exit on wrapped transient DNS/network errors#24582
steipete merged 1 commit into
openclaw:mainfrom
dorukardahan:codex/fix-dns-unhandled-rejection

Conversation

@dorukardahan

@dorukardahan dorukardahan commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

Summary / What changed

  • Harden transient network detection in src/infra/unhandled-rejections.ts.
  • Traverse wrapped error shapes (cause, original, error, data, errors[]) before deciding fatal/non-fatal.
  • Detect transient network codes from nested fields and message text (for wrapped Slack request errors).
  • Add regression coverage in:
    • src/infra/unhandled-rejections.test.ts
    • src/infra/unhandled-rejections.fatal-detection.test.ts

Why

A short DNS failure (EAI_AGAIN) should not terminate the whole gateway process.
Before this change, wrapped request errors could bypass transient detection and trigger process exit, causing restart loops and channel downtime.

Tests

  • pnpm exec vitest run src/infra/unhandled-rejections.test.ts src/infra/unhandled-rejections.fatal-detection.test.ts --config vitest.unit.config.ts

Real-world validation

  • Reproduced and validated on a live Linux VPS on February 23, 2026.
  • During transient DNS instability, gateway no longer exits on wrapped request errors after this patch.

AI-assisted disclosure

  • AI-assisted: yes (Codex).
  • Testing degree: targeted unit/regression tests + live validation.

Issue

Fixes #24581

Greptile Summary

Enhanced transient network error detection to prevent gateway exits on wrapped DNS/network failures by implementing breadth-first traversal of error wrapper structures (cause, original, error, data, errors[]).

  • Traverses nested error shapes to find transient network codes at any depth
  • Adds message-based detection via regex patterns and text snippets for wrapped errors where codes are buried in messages
  • Specifically handles Slack WebAPI request errors that wrap EAI_AGAIN and other network codes in .original field
  • Maintains proper handling order: AbortError → Fatal → Config → Transient → Generic
  • Comprehensive test coverage validates both new wrapper detection and existing behavior

Confidence Score: 5/5

  • Safe to merge with minimal risk
  • Implementation is well-structured with proper circular reference prevention, multiple detection layers for robustness, comprehensive test coverage including edge cases, and maintains backward compatibility while solving a critical production issue
  • No files require special attention

Last reviewed commit: de2d637

@dorukardahan

Copy link
Copy Markdown
Contributor Author

Self-review: second pass update. I kept detection strict for wrapped network errors only. Added a guard test where without network signal stays fatal (no false non-fatal downgrade).

@dorukardahan

Copy link
Copy Markdown
Contributor Author

Self-review (fix): I added a guard test where slack_webapi_request_error without any network indicator is still treated as fatal.

@dorukardahan

dorukardahan commented Feb 23, 2026

Copy link
Copy Markdown
Contributor Author

Update: merged latest main into this branch to resolve conflict. No scope change, only conflict resolution around the same 3 files. Re-ran focused tests locally: vitest unhandled-rejections tests pass.

@steipete
steipete force-pushed the codex/fix-dns-unhandled-rejection branch from 1bfa6f4 to ef0ee91 Compare February 23, 2026 18:27
@steipete
steipete merged commit daaad03 into openclaw:main Feb 23, 2026
4 checks passed
@dorukardahan

Copy link
Copy Markdown
Contributor Author

@arosstale good catch, thank you. We narrowed that regex in main to specific UND_ERR codes, so broad matches are not used now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Gateway can crash-loop on transient DNS failures (EAI_AGAIN)

2 participants