mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 05:27:39 +00:00
fix(telegram): handle network errors gracefully
- Add bot.catch() to prevent unhandled rejections from middleware - Add isRecoverableNetworkError() to retry on transient failures - Add maxRetryTime and exponential backoff to grammY runner - Global unhandled rejection handler now logs recoverable errors instead of crashing (fetch failures, timeouts, connection resets) Fixes crash loop when Telegram API is temporarily unreachable.
This commit is contained in:
committed by
Gustavo Madeira Santana
parent
a8ad242f88
commit
e43f4c0628
@@ -1,5 +1,17 @@
|
||||
import { setDefaultAutoSelectFamily } from "net";
|
||||
import { resolveFetch } from "../infra/fetch.js";
|
||||
|
||||
// Workaround for Node.js 22 "Happy Eyeballs" (autoSelectFamily) bug
|
||||
// that causes intermittent ETIMEDOUT errors when connecting to Telegram's
|
||||
// dual-stack servers. Disabling autoSelectFamily forces sequential IPv4/IPv6
|
||||
// attempts which works reliably.
|
||||
// See: https://github.com/nodejs/node/issues/54359
|
||||
try {
|
||||
setDefaultAutoSelectFamily(false);
|
||||
} catch {
|
||||
// Ignore if not available (older Node versions)
|
||||
}
|
||||
|
||||
// Prefer wrapped fetch when available to normalize AbortSignal across runtimes.
|
||||
export function resolveTelegramFetch(proxyFetch?: typeof fetch): typeof fetch | undefined {
|
||||
if (proxyFetch) return resolveFetch(proxyFetch);
|
||||
|
||||
Reference in New Issue
Block a user