Skip to content

Commit 7ad40a1

Browse files
MarkShawn2020claude
andcommitted
Telegram: only replace global undici dispatcher when autoSelectFamily is enabled
Replacing the global dispatcher unconditionally (even with autoSelectFamily=false) swaps in a bare Agent that discards any configuration the original default dispatcher carried. This breaks other HTTP clients in the same process — notably LLM provider fetches (e.g. Anthropic API) which return HTTP 403 after the dispatcher swap. Only replace the dispatcher when autoSelectFamily is explicitly true, which is the only case where the workaround is actually needed. Fixes #23600 Related: #25682, #25676 Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent a898acb commit 7ad40a1

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/telegram/fetch.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,27 @@ function applyTelegramNetworkWorkarounds(network?: TelegramNetworkConfig): void
4040
// current autoSelectFamily setting so subsequent globalThis.fetch calls
4141
// inherit the same decision.
4242
// See: https://github.com/openclaw/openclaw/issues/25676
43+
//
44+
// IMPORTANT: Only replace the global dispatcher when autoSelectFamily is
45+
// explicitly *enabled*. Replacing it unconditionally (even with false)
46+
// swaps in a bare Agent that discards any configuration the original
47+
// default dispatcher carried, which can break other HTTP clients in the
48+
// same process (e.g. LLM provider fetches returning 403).
4349
if (
44-
autoSelectDecision.value !== null &&
50+
autoSelectDecision.value === true &&
4551
autoSelectDecision.value !== appliedGlobalDispatcherAutoSelectFamily
4652
) {
4753
try {
4854
setGlobalDispatcher(
4955
new Agent({
5056
connect: {
51-
autoSelectFamily: autoSelectDecision.value,
57+
autoSelectFamily: true,
5258
autoSelectFamilyAttemptTimeout: 300,
5359
},
5460
}),
5561
);
56-
appliedGlobalDispatcherAutoSelectFamily = autoSelectDecision.value;
57-
log.info(`global undici dispatcher autoSelectFamily=${autoSelectDecision.value}`);
62+
appliedGlobalDispatcherAutoSelectFamily = true;
63+
log.info(`global undici dispatcher autoSelectFamily=true`);
5864
} catch {
5965
// ignore if setGlobalDispatcher is unavailable
6066
}

0 commit comments

Comments
 (0)