Skip to content

fix(telegram): handle EADDRNOTAVAIL local socket exhaustion correctly [AI-assisted]#94971

Closed
aniruddhaadak80 wants to merge 1 commit into
openclaw:mainfrom
aniruddhaadak80:fix/telegram-eaddrnotavail-fallback
Closed

fix(telegram): handle EADDRNOTAVAIL local socket exhaustion correctly [AI-assisted]#94971
aniruddhaadak80 wants to merge 1 commit into
openclaw:mainfrom
aniruddhaadak80:fix/telegram-eaddrnotavail-fallback

Conversation

@aniruddhaadak80

Copy link
Copy Markdown
Contributor

Summary

This PR resolves an issue where the Telegram transport incorrectly attempts IP-rotation fallback retries when hitting a local socket allocation failure (EADDRNOTAVAIL).

Changes

  • Updated shouldUseTelegramTransportFallback in extensions/telegram/src/fetch.ts to detect EADDRNOTAVAIL error codes or socket allocation failure error messages.
  • If EADDRNOTAVAIL is detected, it logs an accurate warning message ("telegram transport encountered local socket allocation failure (EADDRNOTAVAIL) — check ephemeral ports / mbuf zones / network extensions; remote IP rotation will not help") and returns false to immediately throw the error, skipping unnecessary IP-rotation retries.
  • Added a unit test in extensions/telegram/src/fetch.test.ts to verify the correct handling of EADDRNOTAVAIL socket allocation failures.

Real behavior proof

All tests in extensions/telegram/src/fetch.test.ts pass successfully:

 ✓  extension-telegram  ../../extensions/telegram/src/fetch.test.ts (43 tests) 2246ms
     ✓ normalizes a full bot endpoint apiRoot before callers append bot paths  305ms

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: XS triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 19, 2026
@clawsweeper

clawsweeper Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 21, 2026, 5:42 PM ET / 21:42 UTC.

Summary
The PR adds an EADDRNOTAVAIL fail-fast guard to Telegram fetch fallback classification and a focused unit test.

PR surface: Source +6, Tests +21. Total +27 across 2 files.

Reproducibility: yes. at source level: probeTelegram catches the original getMe error but calls forceFallback with only a reason, and forceFallback logs from a synthetic error. I did not run a live socket-exhaustion repro.

Review metrics: 1 noteworthy metric.

  • Fail-fast transport classification: 1 added: EADDRNOTAVAIL. This changes whether Telegram transport retries or fails fast during local socket allocation failures, so maintainers should review availability impact before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #94620
Summary: This PR is a candidate fix for the canonical Telegram EADDRNOTAVAIL fallback issue, with another open sibling candidate and several closed unmerged same-root attempts.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🧂 unranked krab
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Pass the original probe/client error, or an equivalent local-socket decision, through forced fallback promotion.
  • [P1] Add redacted terminal/log/live output from the Telegram or OS socket-allocation path, or get an explicit maintainer proof override.
  • Coordinate with the open sibling candidate so one complete implementation lands for the canonical issue.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body supplies unit-test output only; it does not show after-fix real Telegram/gateway/OS socket-allocation behavior, so contributor-side proof is still needed before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P2] The reported probe fallback diagnostic can remain reachable because forced fallback does not carry the original EADDRNOTAVAIL into fallback promotion.
  • [P1] The PR body supplies unit-test output only, not redacted live Telegram, gateway, or OS-level socket-allocation proof.
  • [P1] Another open candidate PR targets the same canonical issue, so maintainers should coordinate one complete implementation path before landing.

Maintainer options:

  1. Complete Forced Fallback Handling (recommended)
    Pass the original probe/client error, or an equivalent local-socket decision, through forced fallback promotion and add probe regression coverage before merge.
  2. Coordinate One Candidate Branch
    Compare this PR with fix(telegram): detect EADDRNOTAVAIL and skip misleading IP-rotation fallback #95221 and keep one complete branch for the canonical issue instead of landing overlapping partial fixes.
  3. Require Runtime Proof Or Override
    Ask for redacted live Telegram/gateway/OS logs that exercise EADDRNOTAVAIL, or an explicit maintainer proof override for the rare OS condition.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Pass the original Telegram probe/client fetch error, or an equivalent local-socket-allocation decision, through forceFallback/promotion so EADDRNOTAVAIL skips pinned-IP fallback in both direct fetch and probe-forced fallback paths. Add focused tests for direct fetch EADDRNOTAVAIL, probe/client forced fallback EADDRNOTAVAIL, nested cause/message-only EADDRNOTAVAIL, and unchanged retry behavior for valid fallback errors.

Next step before merge

  • [P2] A narrow automated repair can address the missing forced-fallback propagation and tests, but contributor or maintainer real behavior proof is still required before merge.

Security
Cleared: The diff only changes Telegram fallback classification and tests; it adds no dependency, workflow, secret, permission, install, or publishing surface.

Review findings

  • [P1] Gate forced fallback on the original error — extensions/telegram/src/fetch.ts:476-480
  • [P2] Inspect nested cause messages for EADDRNOTAVAIL — extensions/telegram/src/fetch.ts:476
Review details

Best possible solution:

Land one complete Telegram transport fix that carries EADDRNOTAVAIL through both direct fetch classification and forced fallback promotion while preserving valid timeout and IPv4 recovery fallback.

Do we have a high-confidence way to reproduce the issue?

Yes, at source level: probeTelegram catches the original getMe error but calls forceFallback with only a reason, and forceFallback logs from a synthetic error. I did not run a live socket-exhaustion repro.

Is this the best way to solve the issue?

No. The direct classifier guard is useful but not the best complete fix because forced fallback promotion can still lose EADDRNOTAVAIL before the pinned-IP warning path.

Full review comments:

  • [P1] Gate forced fallback on the original error — extensions/telegram/src/fetch.ts:476-480
    The new guard only runs while the original EADDRNOTAVAIL reaches this predicate. probeTelegram still calls forceFallback with only a reason string, and forceFallback promotes with a synthetic error, so the reported pinned-IP warning can still be emitted with codes=none. Pass the caught error or an equivalent local-socket decision through this boundary and add probe coverage.
    Confidence: 0.94
  • [P2] Inspect nested cause messages for EADDRNOTAVAIL — extensions/telegram/src/fetch.ts:476
    This checks only the top-level error message. Undici wraps network failures as TypeError('fetch failed') with the network error in cause, so a nested message-only EADDRNOTAVAIL without a code would still look like a code-less fetch-failed envelope and retry.
    Confidence: 0.78

Overall correctness: patch is incorrect
Overall confidence: 0.92

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 108d6d7eca00.

Label changes

Label justifications:

  • P2: The PR targets a focused Telegram transport reliability bug with limited blast radius but real incident-triage and retry behavior impact.
  • merge-risk: 🚨 availability: Changing Telegram fallback classification affects whether the channel retries, fails fast, or promotes to pinned-IP fallback during transport errors.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body supplies unit-test output only; it does not show after-fix real Telegram/gateway/OS socket-allocation behavior, so contributor-side proof is still needed before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +6, Tests +21. Total +27 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 6 0 +6
Tests 1 21 0 +21
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 27 0 +27

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs extensions/telegram/src/fetch.test.ts extensions/telegram/src/probe.test.ts extensions/telegram/src/bot.fetch-abort.test.ts.

What I checked:

Likely related people:

  • obviyus: Authored and merged the Telegram transport fallback unification that introduced the ordered sticky IPv4 and pinned-IP fallback chain involved here. (role: feature owner; confidence: high; commits: e4825a0f9385, 4cc25d348a62, ea0a1a785324; files: extensions/telegram/src/fetch.ts, extensions/telegram/src/fetch.test.ts)
  • scoootscooob: Moved the Telegram channel implementation into extensions while preserving the fetch/probe ownership boundary now under review. (role: refactor mover; confidence: medium; commits: e5bca0832fbd, 1719961038ab; files: src/telegram/fetch.ts, src/telegram/probe.ts, extensions/telegram/src/fetch.ts)
  • bosuksh: Authored the earlier Telegram IPv4 fetch fallback work before the implementation moved into extensions. (role: introduced earlier fallback behavior; confidence: medium; commits: 9c03f8be088e, 3818bd2eefdd, c07abb6ca605; files: src/telegram/fetch.ts, src/telegram/fetch.test.ts)
  • Vincent Koc: Current-line blame on the fallback predicate and probe forceFallback path points to a recent snapshot commit, though deeper feature history is more specific. (role: recent area contributor; confidence: low; commits: ebb670b20863; files: extensions/telegram/src/fetch.ts, extensions/telegram/src/probe.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jun 19, 2026
@steipete

Copy link
Copy Markdown
Contributor

Superseded by #97130, landed as 072d3ed.

The landed fix addresses the same Telegram EADDRNOTAVAIL diagnostic path while retaining alternate-IP recovery: Linux ephemeral-port allocation is destination-sensitive, so a different remote Telegram IP can still recover. It forwards the real probe error, removes the misleading DNS assertion, and passed focused tests, Darwin/Linux real-socket proof, autoreview, and exact-head CI.

Thank you, @aniruddhaadak80.

#97130

@steipete steipete closed this Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants