fix(telegram): preserve sticky IPv4 fallback across polling restarts#48184
Open
kiki830621 wants to merge 1 commit intoopenclaw:mainfrom
Open
fix(telegram): preserve sticky IPv4 fallback across polling restarts#48184kiki830621 wants to merge 1 commit intoopenclaw:mainfrom
kiki830621 wants to merge 1 commit intoopenclaw:mainfrom
Conversation
When autoSelectFamily=true (Node 22+ default) and the host has unstable IPv6 routes to api.telegram.org, the fetch layer correctly detects failures and enables a sticky IPv4-only dispatcher. However, each polling restart recreates the bot via createTelegramBot(), which calls resolveTelegramFetch() anew, resetting the sticky state. This causes a repeating cycle: IPv6 timeout → fallback to IPv4 → polling stall → restart → sticky lost → IPv6 timeout again. Fix: resolve the Telegram fetch function once in TelegramPollingSession and reuse it across bot recreations via a new `resolvedFetch` option on createTelegramBot(). The sticky IPv4 fallback state now survives the full polling session lifetime. Fixes openclaw#48177
Contributor
Greptile SummaryThis PR fixes a repeating IPv6-timeout / polling-stall cycle on Node 22+ hosts with unstable IPv6 routes to Key changes:
The implementation is minimal and well-scoped. The abort-signal wrapper and network-error tagging wrapper in Confidence Score: 5/5
Last reviewed commit: 501e27c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
resolveTelegramFetch()once inTelegramPollingSessionconstructor and reuse across bot recreations via newresolvedFetchoptionstickyIpv4FallbackEnabled) now survives the full polling session lifetime instead of resetting on every restartnetworkconfig to polling session so transport is resolved with correct settingsProblem
When
autoSelectFamily=true(Node 22+ default) and the host has unstable IPv6 routes toapi.telegram.org, the fetch layer correctly detects failures and enables a sticky IPv4-only dispatcher. However, each polling restart callscreateTelegramBot()→resolveTelegramFetch(), creating a new fetch closure withstickyIpv4FallbackEnabled = false. This causes a repeating cycle:Observed: 47 polling stalls in 20 hours on a host with residential ISP (unstable IPv6 to Telegram).
Fix
TelegramPollingSessionnow resolves the fetch function once in its constructor and passes it to eachcreateTelegramBot()call viaopts.resolvedFetch. The bot uses the pre-resolved fetch (preserving sticky state) when available, falling back toresolveTelegramFetch()for non-polling callers.Test plan
fetch.test.tsandpolling-session.test.tsstill passautoSelectFamily=true (default-node22)is logged only once per session (not after each restart)resolvedFetchpassed)Fixes #48177