github windkh/node-red-contrib-telegrambot V17.4.0

4 hours ago

V17.4.0 — auto-restart, setwebhook control command, deployment docs

Reliability

  • Auto-restart on fatal bot 'error' event with exponential backoff (3 s, 6 s, 12 s, 24 s, 48 s, capped at 60 s; surrenders after 8 attempts with a node.error). The restart goes through abortBot then a full createTelegramBot, which rebuilds the http.Agent (or SocksProxyAgent) so stale keep-alive sockets and dead proxy connections are flushed.
    • Resolves the recovery half of #442 ("connection breaks after weeks") — no more "bot dies on fatal, manual redeploy needed".
    • Resolves the recovery half of #440 (SOCKS proxy interruption).
  • Single-flight guard on restartPolling. Burst polling_error events now queue at most one 3 s restart instead of stacking N parallel ones — eliminating the "12 cycles in 3 minutes" pattern @petermeter69 reported in #442.

Features

  • Control node "setwebhook" command for dynamic webhook URL updates (#410):
    msg.payload = { command: "setwebhook",
                    url: "https://new-tunnel.example/bot",
                    options: { ... } }
    
    Empty url calls deleteWebHook. Success surfaces as msg.payload.result, failure as msg.error. Only meaningful in webhook mode — Telegram rejects setWebHook while polling is active.

Hardening

  • bot.setMaxListeners(0) (unlimited, hides leaks) → setMaxListeners(50) (covers realistic per-bot listener counts, still catches future regressions of the listener-tracking work).

Documentation

  • New top-level DEPLOYMENT.md covering automated / git-managed deployment patterns. Closes the docs half of #432credentialSecret in settings.js, three deployment patterns, common pitfalls.
  • Architecture documentation set under doc/architecture/ added during the 17.3 cycle (8 chapters + 9 ADRs documenting major design decisions and the V17.2 / V17.3 hardening work).

Test infrastructure (assembled across V17.3.x → V17.4.0)

  • npm test runs 204 cases in ~6 seconds via mocha + chai + c8 + node-red-node-test-helper.
  • A loopback HTTP fixture (test/fixtures/telegram-mock.js) impersonates api.telegram.org for integration tests of the live polling, sending, and setWebHook paths.
  • CI workflow at .github/workflows/ci.yml runs lint + test on Node 18 / 20 / 22 on every push and PR, plus a coverage job that uploads lcov.info as a build artifact.

Overall coverage at release: 70.6 % statement / 68.4 % branch / 84.9 % function. lib/ aggregate at 99.2 %, converter.js and safe-stringify.js at 100 %.

Remaining open items

  • out-node.js per-type switch — 43 % coverage, ~50 case branches. The natural pairing with the recommended table-driven refactor (see doc/architecture/recommendations-for-refactoring.md §2) — refactor + data-driven test together would push this past 95 %.
  • A handful of Dependabot advisories on the deprecated request stack used transitively by node-telegram-bot-api. The durable cure is an upstream refresh; tough-cookie was the only one resolvable via overrides.

Don't miss a new node-red-contrib-telegrambot release

NewReleases is sending notifications on new releases.