7 Commits

Author SHA1 Message Date
Tom Alison
f9afb9ea9c
Merge afec11e21b846b1e5b7b5fb0eb637224173c0093 into 598f1826d8b2bc969aace2c6459824737667218c 2026-03-20 21:08:26 -07:00
Kwest OG
8139f83175
fix(telegram): persist sticky IPv4 fallback across polling restarts (fixes #48177) (#48282)
* fix(telegram): persist sticky IPv4 fallback across polling restarts (fixes #48177)

Hoist resolveTelegramTransport() out of createTelegramBot() so the
transport (and its sticky IPv4 fallback state) persists across polling
restarts. Previously, each polling restart created a new transport with
stickyIpv4FallbackEnabled=false, causing repeated IPv6 timeouts on
hosts with unstable IPv6 connectivity.

Changes:
- bot.ts: accept optional telegramTransport in TelegramBotOptions
- monitor.ts: resolve transport once before polling loop
- polling-session.ts: pass transport through to bot creation

AI-assisted (Claude Sonnet 4). Tested: tsc --noEmit clean.

* Update extensions/telegram/src/polling-session.ts

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* style: fix oxfmt formatting in bot.ts

* test: cover telegram transport reuse across restarts

* fix: preserve telegram sticky IPv4 fallback across polling restarts (#48282) (thanks @yassinebkr)

---------

Co-authored-by: Yassine <yassinebkr@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: Ayaan Zaidi <hi@obviy.us>
2026-03-17 21:56:12 +05:30
Peter Steinberger
9ebe38b6e3
refactor: untangle remaining plugin sdk boundaries 2026-03-16 21:16:32 -07:00
Tom Alison
afec11e21b fix: off-by-one in stall restart escalation
Change >= to > so the process exit fires after MAX_CONSECUTIVE_POLL_RESTARTS
actual restart attempts rather than exiting on the Nth detection before
the Nth restart has a chance to recover. A transient outage that would
recover on the 5th retry no longer gets killed early.
2026-03-14 14:24:45 -07:00
Tom Alison
687d0b4208 fix: promote consecutiveStallRestarts to class field
The counter was declared as a local variable inside #runPollingCycle(),
resetting to 0 on every cycle restart. This made the escalation to
process.exit(1) after MAX_CONSECUTIVE_POLL_RESTARTS dead code since
the counter never accumulated across restarts.

Promote to a private class field (#consecutiveStallRestarts) matching
the pattern used by #restartAttempts, so stall restarts accumulate
correctly and the process-exit escalation works as intended.
2026-03-14 14:12:22 -07:00
Tom Alison
d7a6bed2ed fix(telegram): polling stall recovery fails when grammY retries mask the stall
The polling watchdog tracks getUpdates call initiation, not successful
completion. When the watchdog triggers a restart but recovery fails,
grammY's internal retry mechanism continues making failed getUpdates
calls at intervals shorter than the 90s stall threshold. Each failed
attempt updates lastGetUpdatesAt, fooling the watchdog into thinking
polling is healthy.

This caused a 50-minute outage where the gateway process was alive
(health endpoint returning ok) but Telegram was completely deaf.

Three fixes:
1. Track getUpdates success, not initiation - await prev() before
   updating the timestamp so failed calls don't reset the clock
2. Reset restartAttempts on successful getUpdates - prevents permanent
   backoff growth after genuine recovery
3. Escalate after 5 consecutive stall restarts - process.exit(1) lets
   the process manager (systemd/launchd) do a clean restart

Fixes #44595
2026-03-14 14:12:22 -07:00
scoootscooob
e5bca0832f
refactor: move Telegram channel implementation to extensions/ (#45635)
* refactor: move Telegram channel implementation to extensions/telegram/src/

Move all Telegram channel code (123 files + 10 bot/ files + 8 channel plugin
files) from src/telegram/ and src/channels/plugins/*/telegram.ts to
extensions/telegram/src/. Leave thin re-export shims at original locations so
cross-cutting src/ imports continue to resolve.

- Fix all relative import paths in moved files (../X/ -> ../../../src/X/)
- Fix vi.mock paths in 60 test files
- Fix inline typeof import() expressions
- Update tsconfig.plugin-sdk.dts.json rootDir to "." for cross-directory DTS
- Update write-plugin-sdk-entry-dts.ts for new rootDir structure
- Move channel plugin files with correct path remapping

* fix: support keyed telegram send deps

* fix: sync telegram extension copies with latest main

* fix: correct import paths and remove misplaced files in telegram extension

* fix: sync outbound-adapter with main (add sendTelegramPayloadMessages) and fix delivery.test import path
2026-03-14 02:50:17 -07:00