fix: handle fetch/API errors in telegram delivery to prevent gateway crashes#2492
Merged
thewilloftheshadow merged 2 commits intoopenclaw:mainfrom Jan 27, 2026
Merged
Conversation
…crashes Wrap all bot.api.sendXxx() media calls in delivery.ts with error handler that logs failures before re-throwing. This ensures network failures are properly logged with context instead of causing unhandled promise rejections that crash the gateway. Also wrap the fetch() call in telegram onboarding with try/catch to gracefully handle network errors during username lookup. Fixes openclaw#2487 Co-Authored-By: Claude Opus 4.5 <[email protected]>
d0d70ee to
b3bb956
Compare
Member
thewilloftheshadow
added a commit
that referenced
this pull request
Jan 27, 2026
thewilloftheshadow
added a commit
that referenced
this pull request
Jan 27, 2026
Member
tyler6204
added a commit
that referenced
this pull request
Jan 27, 2026
Summary
bot.api.sendXxx()media calls indelivery.tswith error handler that logs failures before re-throwingProblem
The gateway crashes due to unhandled promise rejections from Telegram API calls. When
bot.api.sendPhoto()(or other media sends) fails due to network issues, the error propagates as an unhandled rejection and triggersprocess.exit(1)in the global handler.Before: Network failure → unhandled rejection → gateway crash
After: Network failure → logged with context → error propagates to caller → graceful handling
Changes
src/telegram/bot/delivery.tsAdded
withMediaErrorHandler()wrapper that:runtime.error()src/channels/plugins/onboarding/telegram.tsWrapped the
fetch()call for username lookup:nullon network errors (user can retry with numeric ID)res.okbefore parsing JSONTest Plan
Fixes #2487
Fixes #2272
🤖 Generated with Claude Code