Skip to content

fix: handle Telegram network errors gracefully to prevent gateway crashes#3013

Merged
thewilloftheshadow merged 2 commits intoopenclaw:mainfrom
ryancontent:fix/telegram-unhandled-fetch-rejections
Jan 28, 2026
Merged

fix: handle Telegram network errors gracefully to prevent gateway crashes#3013
thewilloftheshadow merged 2 commits intoopenclaw:mainfrom
ryancontent:fix/telegram-unhandled-fetch-rejections

Conversation

@ryancontent
Copy link
Copy Markdown
Contributor

Summary

Fix unhandled promise rejections from Telegram API fetch failures that crash the entire gateway, terminating all running agents.

Problem

When Telegram API calls fail due to network issues, unhandled promise rejections can escape error handling and crash the entire gateway. This was observed with ~74 gateway restarts in a single day during network instability.

Solution

  • Expand the set of errors considered "recoverable" for retry (ECONNABORTED, ERR_NETWORK)
  • Add message patterns for common fetch failures ("typeerror: fetch failed", "undici")
  • Add isNetworkRelatedError() helper for broad network failure detection
  • Ensure all network-related errors trigger retry instead of crash
  • Clean up fire-and-forget patterns (remove unnecessary void)

Testing

  • Added unit tests for expanded error detection
  • Verified existing tests pass (pnpm test src/telegram/network-errors.test.ts)

Related Issues

Fixes #3005
Related to #2876

AI Disclosure

This PR was developed with AI assistance (Claude). The code has been reviewed and tested.

@openclaw-barnacle openclaw-barnacle bot added the channel: telegram Channel integration: telegram label Jan 27, 2026
@thewilloftheshadow thewilloftheshadow self-assigned this Jan 28, 2026
ryancontent and others added 2 commits January 27, 2026 19:53
…shes

- Expand recoverable error codes (ECONNABORTED, ERR_NETWORK)
- Add message patterns for 'typeerror: fetch failed' and 'undici' errors
- Add isNetworkRelatedError() helper for broad network failure detection
- Retry on all network-related errors instead of crashing gateway
- Remove unnecessary 'void' from fire-and-forget patterns
- Add tests for new error patterns

Fixes openclaw#3005
@thewilloftheshadow thewilloftheshadow force-pushed the fix/telegram-unhandled-fetch-rejections branch from d65736a to 0d1938a Compare January 28, 2026 01:56
@thewilloftheshadow thewilloftheshadow merged commit 57d9c09 into openclaw:main Jan 28, 2026
16 of 23 checks passed
@thewilloftheshadow
Copy link
Copy Markdown
Member

Landed via temp rebase onto main.

  • Related tests: pnpm vitest run --config vitest.unit.config.ts src/telegram/network-errors.test.ts
  • Land commit: 0d1938a
  • Merge commit: 57d9c09

Thanks @ryancontent!

YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Jan 31, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Feb 1, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Feb 1, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Feb 1, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Feb 1, 2026
YuriNachos pushed a commit to YuriNachos/clawdbot-fork that referenced this pull request Feb 1, 2026
bestNiu pushed a commit to bestNiu/clawdbot that referenced this pull request Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Telegram channel unhandled fetch failures crash entire gateway

2 participants