Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/platforms/telegram/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3060,7 +3060,7 @@ async def _handle_polling_conflict(self, error: Exception) -> None:
raise RuntimeError("Telegram application was torn down during conflict reconnect")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PTB 22.6 defines this flag as dropping pending Telegram updates and forwards it to delete_webhook; it does not establish stale-session termination. This conflicts with the adapter's explicit reconnect contract at adapter.py:3584-3590, which preserves queued messages to avoid silent loss. Please keep preservation unless a supported recovery operation can prove both session cleanup and no message loss.

await self._start_polling_once(
app,
drop_pending_updates=False,
drop_pending_updates=True,
error_callback=self._polling_error_callback_ref,
)
logger.info(
Expand Down
5 changes: 4 additions & 1 deletion tests/gateway/test_telegram_conflict.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ async def test_polling_conflict_retries_before_fatal(monkeypatch):
captured = {}

async def fake_start_polling(**kwargs):
captured["error_callback"] = kwargs["error_callback"]
captured.update(kwargs)
# Cold connect requires real getUpdates readiness (#67498) — simulate
# the first successful poll for the generation this call started, but
# only on the initial connect: the conflict-retry generation must NOT
Expand Down Expand Up @@ -131,6 +131,9 @@ async def fake_start_polling(**kwargs):
await adapter._polling_error_task

assert adapter.has_fatal_error is False, "First conflict should not be fatal"
assert captured["drop_pending_updates"] is True, (
"Conflict recovery must ask Telegram to terminate stale getUpdates sessions"
)
assert adapter._polling_conflict_count == 1, (
"Count must remain until the retried generation makes getUpdates progress"
)
Expand Down