Skip to content

Telegram media group fetch intermittently fails on Node.js 25 (undici IPv6) #36010

@VashikMart

Description

@VashikMart

Description

Intermittent TypeError: fetch failed when downloading photos from Telegram media groups (multiple photos sent at once). Single photo messages work fine.

Environment

  • OpenClaw: 2026.3.1 (stable)
  • Node.js: 25.6.1 (arm64, macOS 26.3)
  • OS: macOS Sequoia 26.3 (Apple Silicon)

Error

[telegram] media group: skipping photo that failed to fetch: MediaFetchError: Failed to fetch media from https://api.telegram.org/file/bot<token>/photos/file_XXXX.jpg: TypeError: fetch failed

Frequency

  • 5 failures across 8 days (Feb 26 – Mar 4)
  • Only happens with media groups (multiple photos), never single photo messages
  • 1 out of N photos in a group fails, rest download fine

Root cause suspicion

Node.js 25 undici HTTP client + IPv6 resolution. When multiple concurrent fetches hit api.telegram.org, one occasionally fails due to IPv6/IPv4 race condition.

Workarounds applied (partial fix)

  1. /etc/hosts: 149.154.166.110 api.telegram.org (force IPv4)
  2. NODE_OPTIONS=--dns-result-order=ipv4first in LaunchAgent plist
  3. Patched all ssrf-*.js files: added family: 4 to dispatcher options
  4. These reduced frequency but didn't eliminate it completely

Related

Suggestion

Consider adding a retry mechanism for media group photo downloads — if one fetch fails, retry once before skipping. This would eliminate the user-visible error for intermittent network issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions