Skip to content

fix(telegram): enable autoSelectFamily by default for Node.js 22+#18272

Merged
steipete merged 2 commits intoopenclaw:mainfrom
nacho9900:fix/telegram-autoselectfamily-ipv6
Feb 16, 2026
Merged

fix(telegram): enable autoSelectFamily by default for Node.js 22+#18272
steipete merged 2 commits intoopenclaw:mainfrom
nacho9900:fix/telegram-autoselectfamily-ipv6

Conversation

@nacho9900
Copy link

@nacho9900 nacho9900 commented Feb 16, 2026

Problem

Telegram plugin fails to send messages when IPv6 is configured but not functional on the network (common in many regions, especially Latin America).

Fixes #18279

Symptoms

  • ❌ Health check shows: Telegram │ WARN │ failed (unknown) - fetch failed
  • ❌ Bot receives messages but cannot send replies
  • ❌ Logs: Network request for 'sendMessage' failed
  • ❌ IPv6 connection attempt: Network is unreachable

Root Cause

The current default (autoSelectFamily=false for Node.js 22+) prevents Node from falling back to IPv4 when IPv6 fails. This breaks Telegram on networks where:

  1. IPv6 is configured in the OS
  2. But not properly routed by ISP/router
  3. Curl with -4 works fine, but Node.js fails

Solution

Change the default from false to true for Node.js 22+:

- return { value: false, source: "default-node22" };
+ return { value: true, source: "default-node22" };

This enables automatic IPv4 fallback when IPv6 fails, matching standard Node.js behavior.

Backward Compatibility

  • ✅ Config option channels.telegram.network.autoSelectFamily still available for override
  • ✅ Environment variables OPENCLAW_TELEGRAM_ENABLE_AUTO_SELECT_FAMILY and OPENCLAW_TELEGRAM_DISABLE_AUTO_SELECT_FAMILY still work
  • ✅ No breaking changes

Testing

Tested on:

  • macOS 26.2 (Sequoia)
  • Node.js v22.15.0
  • OpenClaw 2026.2.12
  • Network: IPv6 configured but not routed

Before fix:

$ openclaw status --deep
Telegram │ WARN │ failed (unknown) - fetch failed

After fix:

$ openclaw status --deep
Telegram │ OK │ ok (@bot:default:1540ms)

Changes in this PR

  • src/telegram/network-config.ts: Change default from false to true
  • src/telegram/network-config.test.ts: Update test expectation
  • src/telegram/fetch.ts: Update comment to reflect new behavior

Note: The original hardcoded false was likely added as a workaround for Node.js 22 compatibility, but it causes more problems than it solves. The true default is safer for most networks and matches standard Node.js behavior.

Fixes issue where Telegram fails to send messages when IPv6 is configured
but not functional on the network.

Problem:
- Many networks (especially in Latin America) have IPv6 configured but
  not properly routed by ISP/router
- Node.js tries IPv6 first, gets 'Network is unreachable' error
- With autoSelectFamily=false, Node doesn't fallback to IPv4
- Result: All Telegram API calls fail

Solution:
- Change default from false to true for Node.js 22+
- This enables automatic IPv4 fallback when IPv6 fails
- Config option channels.telegram.network.autoSelectFamily still available
  for users who need to override

Symptoms fixed:
- Health check: Telegram | WARN | failed (unknown) - fetch failed
- Logs: Network request for 'sendMessage' failed
- Bot receives messages but cannot send replies

Tested on:
- macOS 26.2 (Sequoia)
- Node.js v22.15.0
- OpenClaw 2026.2.12
- Network with IPv6 configured but not routed
@openclaw-barnacle openclaw-barnacle bot added channel: telegram Channel integration: telegram size: XS labels Feb 16, 2026
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 16, 2026

Additional Comments (2)

src/telegram/network-config.test.ts
Test expects old default value
This test still asserts value: false for the Node 22 default, but the implementation now returns true. This test will fail. The test name and assertion need to be updated to reflect the new behavior.

  it("defaults to enable on Node 22", () => {
    const decision = resolveTelegramAutoSelectFamilyDecision({ env: {}, nodeMajor: 22 });
    expect(decision).toEqual({ value: true, source: "default-node22" });
  });
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/telegram/network-config.test.ts
Line: 39:42

Comment:
**Test expects old default value**
This test still asserts `value: false` for the Node 22 default, but the implementation now returns `true`. This test will fail. The test name and assertion need to be updated to reflect the new behavior.

```suggestion
  it("defaults to enable on Node 22", () => {
    const decision = resolveTelegramAutoSelectFamilyDecision({ env: {}, nodeMajor: 22 });
    expect(decision).toEqual({ value: true, source: "default-node22" });
  });
```

How can I resolve this? If you propose a fix, please make it concise.

src/telegram/fetch.ts
Stale comment contradicts new behavior
This comment says "disable autoSelectFamily" but the default behavior for Node 22+ is now to enable it. Consider updating the comment to reflect the new intent, e.g.:

// Node 22 workaround: enable autoSelectFamily for IPv4 fallback on broken IPv6 networks.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/telegram/fetch.ts
Line: 10:10

Comment:
**Stale comment contradicts new behavior**
This comment says "disable autoSelectFamily" but the default behavior for Node 22+ is now to *enable* it. Consider updating the comment to reflect the new intent, e.g.:

```suggestion
// Node 22 workaround: enable autoSelectFamily for IPv4 fallback on broken IPv6 networks.
```

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

- Update test expectation: 'defaults to enable on Node 22'
- Update comment in fetch.ts to explain IPv4 fallback rationale
- Addresses greptile review feedback
@steipete steipete merged commit d43c11c into openclaw:main Feb 16, 2026
23 checks passed
@sebslight sebslight self-assigned this Feb 17, 2026
@nacho9900 nacho9900 deleted the fix/telegram-autoselectfamily-ipv6 branch February 17, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Telegram fails to send messages on networks with non-functional IPv6 (autoSelectFamily=false)

3 participants