mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 13:44:58 +00:00
fix(telegram): disable autoSelectFamily by default on WSL2 (#21916)
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: 431fd96670
Co-authored-by: MizukiMachine <185313792+MizukiMachine@users.noreply.github.com>
Co-authored-by: obviyus <22031114+obviyus@users.noreply.github.com>
Reviewed-by: @obviyus
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import process from "node:process";
|
||||
import type { TelegramNetworkConfig } from "../config/types.telegram.js";
|
||||
import { isTruthyEnvValue } from "../infra/env.js";
|
||||
import { isWSL2Sync } from "../infra/wsl.js";
|
||||
|
||||
export const TELEGRAM_DISABLE_AUTO_SELECT_FAMILY_ENV =
|
||||
"OPENCLAW_TELEGRAM_DISABLE_AUTO_SELECT_FAMILY";
|
||||
@@ -11,6 +12,16 @@ export type TelegramAutoSelectFamilyDecision = {
|
||||
source?: string;
|
||||
};
|
||||
|
||||
let wsl2SyncCache: boolean | undefined;
|
||||
|
||||
function isWSL2SyncCached(): boolean {
|
||||
if (typeof wsl2SyncCache === "boolean") {
|
||||
return wsl2SyncCache;
|
||||
}
|
||||
wsl2SyncCache = isWSL2Sync();
|
||||
return wsl2SyncCache;
|
||||
}
|
||||
|
||||
export function resolveTelegramAutoSelectFamilyDecision(params?: {
|
||||
network?: TelegramNetworkConfig;
|
||||
env?: NodeJS.ProcessEnv;
|
||||
@@ -31,8 +42,16 @@ export function resolveTelegramAutoSelectFamilyDecision(params?: {
|
||||
if (typeof params?.network?.autoSelectFamily === "boolean") {
|
||||
return { value: params.network.autoSelectFamily, source: "config" };
|
||||
}
|
||||
// WSL2 has unstable IPv6 connectivity; disable autoSelectFamily to use IPv4 directly
|
||||
if (isWSL2SyncCached()) {
|
||||
return { value: false, source: "default-wsl2" };
|
||||
}
|
||||
if (Number.isFinite(nodeMajor) && nodeMajor >= 22) {
|
||||
return { value: true, source: "default-node22" };
|
||||
}
|
||||
return { value: null };
|
||||
}
|
||||
|
||||
export function resetTelegramNetworkConfigStateForTests(): void {
|
||||
wsl2SyncCache = undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user