openclaw/src/telegram
Glucksberg 481bd333eb
fix(gateway): gracefully handle AbortError and transient network errors (#2451)
* fix(tts): generate audio when block streaming drops final reply

When block streaming succeeds, final replies are dropped but TTS was only
applied to final replies. Fix by accumulating block text during streaming
and generating TTS-only audio after streaming completes.

Also:
- Change truncate vs skip behavior when summary OFF (now truncates)
- Align TTS limits with Telegram max (4096 chars)
- Improve /tts command help messages with examples
- Add newline separator between accumulated blocks

* fix(tts): add error handling for accumulated block TTS

* feat(tts): add descriptive inline menu with action descriptions

- Add value/label support for command arg choices
- TTS menu now shows descriptive title listing each action
- Capitalize button labels (On, Off, Status, etc.)
- Update Telegram, Discord, and Slack handlers to use labels

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(gateway): gracefully handle AbortError and transient network errors

Addresses issues #1851, #1997, and #2034.

During config reload (SIGUSR1), in-flight requests are aborted, causing
AbortError exceptions. Similarly, transient network errors (fetch failed,
ECONNRESET, ETIMEDOUT, etc.) can crash the gateway unnecessarily.

This change:
- Adds isAbortError() to detect intentional cancellations
- Adds isTransientNetworkError() to detect temporary connectivity issues
- Logs these errors appropriately instead of crashing
- Handles nested cause chains and AggregateError

AbortError is logged as a warning (expected during shutdown).
Network errors are logged as non-fatal errors (will resolve on their own).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(test): update commands-registry test expectations

Update test expectations to match new ResolvedCommandArgChoice format
(choices now return {label, value} objects instead of plain strings).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: harden unhandled rejection handling and tts menus (#2451) (thanks @Glucksberg)

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Shadow <hi@shadowing.dev>
2026-01-26 19:51:53 -06:00
..
bot fix: telegram sendPayload and plugin auth (#1917) (thanks @JoshuaLelon) 2026-01-26 22:28:14 +05:30
accounts.test.ts fix: align channel config schemas and env precedence 2026-01-17 00:43:05 +00:00
accounts.ts CLI: streamline startup paths and env parsing 2026-01-18 23:10:39 +00:00
allowed-updates.ts fix: refine telegram reactions (#964) (thanks @bohdanpodvirnyi) 2026-01-15 17:20:17 +00:00
audit.test.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
audit.ts fix: normalize gateway dev mode detection 2026-01-18 01:08:47 +00:00
bot-access.ts fix: stabilize ci checks 2026-01-19 00:34:26 +00:00
bot-handlers.ts fix(telegram): answer callback queries immediately to prevent retries 2026-01-21 03:04:28 +00:00
bot-message-context.dm-threads.test.ts Telegram: threaded conversation support (#1597) 2026-01-25 04:48:51 +00:00
bot-message-context.sender-prefix.test.ts fix(auth): skip auth profiles in cooldown during selection and rotation 2026-01-23 03:28:18 +00:00
bot-message-context.ts Telegram: threaded conversation support (#1597) 2026-01-25 04:48:51 +00:00
bot-message-dispatch.ts feat(telegram): add linkPreview config option 2026-01-25 06:00:05 +00:00
bot-message.test.ts fix: emit diagnostics across channels 2026-01-21 00:30:34 +00:00
bot-message.ts fix: emit diagnostics across channels 2026-01-21 00:30:34 +00:00
bot-native-commands.plugin-auth.test.ts fix: telegram sendPayload and plugin auth (#1917) (thanks @JoshuaLelon) 2026-01-26 22:28:14 +05:30
bot-native-commands.ts fix(gateway): gracefully handle AbortError and transient network errors (#2451) 2026-01-26 19:51:53 -06:00
bot-updates.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
bot.create-telegram-bot.accepts-group-messages-mentionpatterns-match-without-botusername.test.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
bot.create-telegram-bot.applies-topic-skill-filters-system-prompts.test.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
bot.create-telegram-bot.blocks-all-group-messages-grouppolicy-is.test.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
bot.create-telegram-bot.dedupes-duplicate-callback-query-updates-by-update.test.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
bot.create-telegram-bot.installs-grammy-throttler.test.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
bot.create-telegram-bot.matches-tg-prefixed-allowfrom-entries-case-insensitively.test.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
bot.create-telegram-bot.matches-usernames-case-insensitively-grouppolicy-is.test.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
bot.create-telegram-bot.routes-dms-by-telegram-accountid-binding.test.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
bot.create-telegram-bot.sends-replies-without-native-reply-threading.test.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
bot.media.downloads-media-file-path-no-file-download.test.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
bot.media.includes-location-text-ctx-fields-pins.test.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
bot.test.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
bot.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
caption.ts refactor: share telegram caption splitting 2026-01-17 03:50:09 +00:00
download.test.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
download.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
draft-chunking.test.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
draft-chunking.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
draft-stream.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
fetch.test.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
fetch.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
format.test.ts fix: telegram html formatting (#435, thanks @RandyVentures) 2026-01-08 02:34:32 +01:00
format.ts fix: render Telegram media captions 2026-01-24 03:39:25 +00:00
group-migration.test.ts fix(telegram): migrate group config on supergroup IDs (#906) 2026-01-15 01:10:30 +00:00
group-migration.ts Format: fix report + telegram formatting 2026-01-15 01:27:16 +00:00
index.ts feat: unify provider reaction tools 2026-01-07 04:16:39 +01:00
inline-buttons.test.ts refactor: prune legacy group targets 2026-01-17 09:01:47 +00:00
inline-buttons.ts fix: allow telegram prefixes/topics for inline buttons (#1072) — thanks @danielz1z 2026-01-17 07:49:57 +00:00
monitor.test.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
monitor.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
network-config.test.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
network-config.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
network-errors.test.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
network-errors.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
pairing-store.test.ts fix(security): lock down inbound DMs by default 2026-01-06 17:51:56 +01:00
pairing-store.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
probe.ts fix: normalize gateway dev mode detection 2026-01-18 01:08:47 +00:00
proxy.ts fix: normalize abort signals for telegram fetch 2026-01-21 16:46:58 +00:00
reaction-level.test.ts feat: default telegram reaction level minimal 2026-01-16 20:35:47 +00:00
reaction-level.ts feat: default telegram reaction level minimal 2026-01-16 20:35:47 +00:00
send.caption-split.test.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
send.edit-message.test.ts feat(telegram): add edit message action (#2394) (thanks @marcelomar21) 2026-01-26 15:34:47 -08:00
send.preserves-thread-params-plain-text-fallback.test.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
send.proxy.test.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
send.returns-undefined-empty-input.test.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
send.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
sent-message-cache.test.ts fix: lint errors 2026-01-15 17:07:38 +00:00
sent-message-cache.ts fix: lint errors 2026-01-15 17:07:38 +00:00
targets.test.ts refactor: prune legacy group targets 2026-01-17 09:01:47 +00:00
targets.ts refactor: prune legacy group targets 2026-01-17 09:01:47 +00:00
token.test.ts fix: prefer config tokens over env for discord/telegram 2026-01-16 23:13:00 +00:00
token.ts fix: prefer config tokens over env for discord/telegram 2026-01-16 23:13:00 +00:00
update-offset-store.test.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
update-offset-store.ts chore: migrate to oxlint and oxfmt 2026-01-14 15:02:19 +00:00
voice.test.ts refactor: consolidate reply/media helpers 2026-01-10 02:41:16 +01:00
voice.ts refactor: unify inline directives and media fetch 2026-01-10 03:01:04 +01:00
webhook-set.ts Telegram: harden network retries and config 2026-01-26 19:36:43 -05:00
webhook.test.ts fix: refine telegram reactions (#964) (thanks @bohdanpodvirnyi) 2026-01-15 17:20:17 +00:00
webhook.ts fix: emit diagnostics across channels 2026-01-21 00:30:34 +00:00