fix(telegram): increase dedup TTL and log offset confirmation failures
The Telegram update dedup cache had a 5-minute TTL which could expire during extended polling restart cycles (backoff, stall detection, etc.), allowing already-processed messages to be re-delivered. - Increase dedup cache TTL from 5 to 30 minutes to survive all realistic restart windows - Increase max cache size from 2000 to 5000 to match the longer TTL - Log a warning when confirmPersistedOffset fails so operators can diagnose duplicate-message issues Closes #46674
This commit is contained in:
parent
5e417b44e1
commit
f4c69a6cfc
@ -3,8 +3,11 @@ import { createDedupeCache } from "openclaw/plugin-sdk/infra-runtime";
|
||||
import type { TelegramContext } from "./bot/types.js";
|
||||
|
||||
const MEDIA_GROUP_TIMEOUT_MS = 500;
|
||||
const RECENT_TELEGRAM_UPDATE_TTL_MS = 5 * 60_000;
|
||||
const RECENT_TELEGRAM_UPDATE_MAX = 2000;
|
||||
// Dedup cache TTL must survive the longest possible polling restart cycle
|
||||
// (backoff up to 30s × multiple attempts + 90s stall threshold + 15s grace).
|
||||
// 30 minutes keeps entries alive well past any realistic restart window (#46674).
|
||||
const RECENT_TELEGRAM_UPDATE_TTL_MS = 30 * 60_000;
|
||||
const RECENT_TELEGRAM_UPDATE_MAX = 5000;
|
||||
|
||||
export type MediaGroupEntry = {
|
||||
messages: Array<{
|
||||
|
||||
@ -177,8 +177,12 @@ export class TelegramPollingSession {
|
||||
}
|
||||
try {
|
||||
await bot.api.getUpdates({ offset: lastUpdateId + 1, limit: 1, timeout: 0 });
|
||||
} catch {
|
||||
} catch (err) {
|
||||
// Non-fatal: runner middleware still skips duplicates via shouldSkipUpdate.
|
||||
// Log a warning so operators can diagnose duplicate-message issues (#46674).
|
||||
this.opts.log(
|
||||
`[telegram] failed to confirm persisted offset ${lastUpdateId}: ${formatErrorMessage(err)}; relying on dedup cache.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user