Skip to content

Deduplicate repeated Telegram webhook updates - #799

Open
onmax wants to merge 1 commit into
vercel:mainfrom
vite-hub:agent/telegram-webhook-dedupe
Open

Deduplicate repeated Telegram webhook updates#799
onmax wants to merge 1 commit into
vercel:mainfrom
vite-hub:agent/telegram-webhook-dedupe

Conversation

@onmax

@onmax onmax commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Telegram retries webhook deliveries after non-2xx responses, and its update_id field is explicitly intended for ignoring repeated updates. The Telegram adapter previously routed every webhook delivery independently.

This change atomically claims each integer update_id through the configured StateAdapter before routing the update. Repeated deliveries return 200 without reaching bot handlers, while state failures return 503 without dispatching so Telegram can retry. Updates without an integer update_id keep their existing behavior, and polling remains unchanged.

Claims expire after 24 hours because Telegram retains incoming updates for no longer than 24 hours. This is a bounded retention choice, not a documented retry timeout. Cross-instance deduplication requires shared durable state; in-memory state only protects one process. The change provides webhook-delivery idempotency, not end-to-end exactly-once handler completion.

Telegram contract: Update and setWebhook.

Test plan

  • pnpm --filter @chat-adapter/telegram test
  • pnpm --filter @chat-adapter/telegram typecheck
  • pnpm check
  • pnpm konsistent
  • TURBO_CONCURRENCY=1 pnpm validate

Regression coverage verifies sequential and concurrent repeated deliveries, distinct update IDs, missing update IDs, duplicate 200 responses, and state-failure retry behavior. GitHub CI also passes on Node 22 and Node 24.

Checklist

  • All commits are signed and verified
  • All commits are signed off for the DCO (git commit -s)
  • pnpm validate passes
  • Changeset added (or N/A — see CONTRIBUTING.md)
  • Documentation updated (or N/A)

Signed-off-by: onmax <maximogarciamtnez@gmail.com>
@onmax
onmax requested a review from a team as a code owner August 8, 2026 08:51
@vercel

vercel Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

@onmax is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant