Skip to content

[Bug] Telegram media fetch fails on IPv6-broken hosts (Node 24 dns-result-order not respected) #23975

@jasonshannon77

Description

@jasonshannon77

Description

Telegram media downloads (photos sent by users) fail with MediaFetchError: TypeError: fetch failed on hosts where IPv6 is not working.

Environment

  • OpenClaw: 2026.2.21-2
  • Node: v24.13.0
  • OS: Ubuntu Linux (AWS EC2)
  • Channel: Telegram

Symptoms

  • All inbound Telegram photo attachments fail to download
  • Error in logs: MediaFetchError: Failed to fetch media from https://api.telegram.org/file/bot.../photos/file_XXX.jpg: TypeError: fetch failed
  • IPv4 connections to api.telegram.org succeed, IPv6 fails (curl -4 works, curl -6 returns 000)
  • Node 24 defaults to IPv6-first (happy eyeballs / verbatim DNS result order)

Attempted Workarounds

  • Setting NODE_OPTIONS=--dns-result-order=ipv4first in the systemd service file — not respected for media fetch operations
  • The gateway process itself works fine (WebSocket, API calls) — only the media download path is affected

Expected Behavior

Media fetch should respect the Node DNS result order setting, or implement its own IPv4 fallback when IPv6 connections fail.

Suggested Fix

Either:

  1. Pass family: 4 as a fetch option when downloading Telegram files
  2. Implement retry logic that falls back to IPv4 on connection failure
  3. Respect NODE_OPTIONS=--dns-result-order=ipv4first in the media fetch code path

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions