fix(telegram): use sticky IPv4 fallback on dual-stack failures#40435
fix(telegram): use sticky IPv4 fallback on dual-stack failures#40435sircrumpet wants to merge 4 commits intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR fixes a user-facing Telegram bot breakage in dual-stack environments where outbound Key changes:
Note on design: Confidence Score: 4/5
|
|
@greptile-apps Updated code comment for clarity. Thanks, regarding the sticky flag, this was considered and the current behavior is intentional. |
|
Got it, that makes sense. Per-resolver stickiness gives you the recovery opportunity on recreate while avoiding permanent IPv4 lock-in process-wide. The tradeoff is reasonable - better to probe once per resolver lifecycle than stay stuck on IPv4 after a transient blip. Thanks for clarifying the comment. |
|
Closing this as superseded by #40740. This PR improved fallback behavior (sticky IPv4 + preserving caller dispatcher), but it still kept Telegram’s global transport mutation path in The replacement PR keeps the same user-facing goal (recover from dual-stack failures) while moving to resolver-scoped transport policy:
|
Summary
Describe the problem and fix in 2–5 bullets:
sendMessage/sendChatActionnetwork failures), effectively breaking agent responses.A workaround exists (and has been suggested in related issues) where updating channels.telegram.network to:
biases Telegram toward IPv4 and avoids Node’s auto-select behavior.
This PR handles the failure path automatically: when Telegram hits qualifying dual-stack connect errors, it falls back to IPv4 and stays there for that resolver lifecycle. So users who don’t know they need a network override still recover, and users with custom dispatchers/proxy routing are protected because fallback no longer overwrites caller-provided dispatchers.
family: 4) instead of repeatedly mutating transport behavior.init.dispatcherduring fallback retry.EnvHttpProxyAgentcan still be refreshed with Telegram connect options.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Closes: [Bug]: Telegram inbound messages not reaching agent after v2026.2.19-2 update #21737
Related: [Bug]: Telegram inbound messages received as raw updates but never dispatched to session #19454
Related fix(telegram): add dnsResultOrder=ipv4first default on Node 22+ to fix fetch failures #5405
Related 2026.2.23 regression: all outbound Telegram API calls fail with TypeError: fetch failed (Node 22 undici) #25676
Related telegram: retry media fetch with IPv4 fallback on connect errors #30554
Related: fix(telegram): disable autoSelectFamily by default on Node 22+ #24259
User-visible / Behavior Changes
Security Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation:Repro + Verification
Environment
channels.telegram.network.autoSelectFamilynot set.Steps
Expected
Actual
sendMessage/sendChatActionfailed).Evidence
Attach at least one:
Before (user logs, broken outbound replies):
After (tests/build on this branch):
Added/updated tests in
src/telegram/fetch.test.tscover:EnvHttpProxyAgentrefresh behavior,dispatcherduring fallback retry.Human Verification (required)
What you personally verified (not just CI), and how:
EnvHttpProxyAgentgets refreshed to apply connect options.Review Conversations
If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.
Compatibility / Migration
Yes)No)No)Failure Recovery (if this breaks)
src/telegram/fetch.tssrc/telegram/fetch.test.tsRisks and Mitigations
Risk:
Risk:
init.dispatcher.AI-assisted: Codex for Investigation, review of git history / related items, root cause analysis
Testing level: Targeted unit test + build, tested resolution of fix before + after applying branch.