-
-
Notifications
You must be signed in to change notification settings - Fork 52.8k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description
The Telegram provider causes the entire gateway to crash when network errors occur during getUpdates polling. The error manifests as:
Unhandled promise rejection: TypeError: fetch failed
at node:internal/deps/undici/undici:13510:13
at processTicksAndRejections (node:internal/process/task_queues:105:5)
Root Cause
In src/telegram/monitor.ts, the error handling only catches and retries 409 conflicts (when another bot instance is polling). All other errors, including network failures, are rethrown and crash the gateway:
// Lines 151-157 in monitor.ts
if (!isGetUpdatesConflict(err)) {
throw err; // <-- This crashes the gateway on network errors
}Expected Behavior
Network errors (fetch failures, timeouts, DNS issues) should be caught and retried with backoff, similar to how 409 conflicts are handled. The gateway should not crash due to transient network issues.
Reproduction
- Start the gateway with Telegram enabled
- The gateway crashes approximately 30-60 seconds after Telegram provider starts
- Error message:
TypeError: fetch failed
Environment
- OS: Windows 11
- Node.js: v22.x
- Clawdbot version: 2026.1.20
Suggested Fix
Add network error handling to the catch block in monitorTelegramProvider:
const isNetworkError = (err: unknown) => {
if (!err || typeof err !== 'object') return false;
const message = String((err as { message?: string }).message ?? '');
return message.includes('fetch failed') ||
message.includes('ECONNREFUSED') ||
message.includes('ETIMEDOUT') ||
message.includes('ENOTFOUND');
};
// In the catch block:
if (!isGetUpdatesConflict(err) && !isNetworkError(err)) {
throw err;
}
// Retry with backoff for both conflicts and network errorsWorkaround
Disable Telegram in clawdbot.json:
"plugins": {
"entries": {
"telegram": { "enabled": false }
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working