Skip to content

Commit 3855200

Browse files
committed
fix(#82957): route Telegram polling [diag] lines through info channel, not error
`extensions/telegram/src/monitor.ts:111` previously hard-coded: const log = opts.runtime?.error ?? console.error; so every line emitted by the monitor and every line bubbled from `TelegramPollingSession.opts.log` ended up on the runtime's error channel. Normal lifecycle diagnostics ("polling cycle started", "rebuilding transport for next polling cycle", "waited for previous polling session", etc.) were therefore styled as gateway errors in the console, breaking the visual distinction between expected lifecycle output and actual failures. `[telegram][diag]` is the established info-level marker in this extension. polling-session.ts:260 itself wraps incoming `info: ...` messages into `[telegram][diag] ${msg}` before forwarding, confirming the intent. Other extensions (twitch monitor.ts:193, nextcloud-talk room-info.ts:105, zalo monitor.webhook.ts:146, signal daemon.ts:96, feishu card-action.ts:155/298) consistently use `runtime?.log` for info and `runtime?.error` for error. Fix: split the single `log` into a dispatch that picks the channel based on the `[telegram][diag]` prefix: const logInfo = opts.runtime?.log ?? console.log; const logError = opts.runtime?.error ?? console.error; const log = (line: string) => (line.includes("[telegram][diag]") ? logInfo : logError)(line); After this change, lines like "polling cycle started ..." land on the info channel; only true failures ("Restarting polling after ...", "reconnect delivery drain failed: ...") stay on error.
1 parent 37806af commit 3855200

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

extensions/telegram/src/monitor.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,17 @@ async function loadTelegramMonitorWebhookRuntime() {
108108
}
109109

110110
export async function monitorTelegramProvider(opts: MonitorTelegramOpts = {}) {
111-
const log = opts.runtime?.error ?? console.error;
111+
// `[telegram][diag] ...` lines are normal lifecycle diagnostics (polling
112+
// cycle start, transport rebuild, lease wait, etc.) — they were previously
113+
// routed through `runtime.error`, so normal startup looked like a gateway
114+
// error in the console. Route the diagnostic prefix through the info
115+
// channel (matching twitch / polling-session / zalo conventions), keep the
116+
// raw `runtime.error` path for genuine failures.
117+
// Fixes #82957.
118+
const logInfo = opts.runtime?.log ?? console.log;
119+
const logError = opts.runtime?.error ?? console.error;
120+
const log = (line: string) =>
121+
(line.includes("[telegram][diag]") ? logInfo : logError)(line);
112122
let pollingSession: TelegramPollingSessionInstance | undefined;
113123

114124
const handlePollingNetworkFailure = (err: unknown, label: string) => {

0 commit comments

Comments
 (0)