fix(telegram): add retry logic to health probe (openclaw#7405) thanks @mcinteerj

Verified:
- CI=true pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test

Co-authored-by: mcinteerj <3613653+mcinteerj@users.noreply.github.com>
This commit is contained in:
Jake
2026-02-13 04:11:35 +13:00
committed by GitHub
parent 5554fd23cc
commit 6b1f485ce8
2 changed files with 163 additions and 1 deletions

View File

@@ -35,7 +35,26 @@ export async function probeTelegram(
};
try {
const meRes = await fetchWithTimeout(`${base}/getMe`, {}, timeoutMs, fetcher);
let meRes: Response | null = null;
let fetchError: unknown = null;
// Retry loop for initial connection (handles network/DNS startup races)
for (let i = 0; i < 3; i++) {
try {
meRes = await fetchWithTimeout(`${base}/getMe`, {}, timeoutMs, fetcher);
break;
} catch (err) {
fetchError = err;
if (i < 2) {
await new Promise((resolve) => setTimeout(resolve, 1000));
}
}
}
if (!meRes) {
throw fetchError;
}
const meJson = (await meRes.json()) as {
ok?: boolean;
description?: string;