Why it matters
Telegram long polling must run as a single flight per token — two pollers steal updates from each other and create races.
Practical steps
- Guard startup with a lock (DB advisory lock, Redis SET NX, or flock).
- Exit non-zero if another poller holds the lock.
- Prefer webhooks in multi-instance deploys.
- On shutdown, stop getUpdates before closing DB pools.
- Log offset commits so you can debug gaps.
Watch out for
- Running polling in Kubernetes with replicas>1 and no lock.
- Mixing webhook and polling on the same token.