fix(telegram): route polling diagnostics away from errors · openclaw/openclaw@b5c1199
galiniliev
·
2026-05-25
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -11,6 +11,7 @@ Docs: https://docs.openclaw.ai
|
11 | 11 | - Config: keep benign legacy metadata write anomalies out of default doctor and config command output while preserving explicit anomaly logging for diagnostics. |
12 | 12 | - Codex: log when implicit app-server `never` approvals are promoted for OpenClaw tool policy, including whether the trigger was a `before_tool_call` hook or trusted tool policy. |
13 | 13 | - Google Vertex: support production ADC modes such as Workload Identity Federation, service-account credentials, and metadata-server ADC for the native Vertex transport. (#83971) Thanks @damianFelixPago. |
| 14 | +- Telegram: route normal `[telegram][diag]` polling diagnostics through `runtime.log` while keeping non-diag warnings and persistence failures on `runtime.error`, so healthy polling startup no longer looks like an error. Fixes #82957. (#82958) Thanks @galiniliev. |
14 | 15 | |
15 | 16 | ## 2026.5.25 |
16 | 17 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -472,6 +472,46 @@ describe("monitorTelegramProvider (grammY)", () => {
|
472 | 472 | expect(runOptions?.runner?.retryInterval).toBe("exponential"); |
473 | 473 | }); |
474 | 474 | |
| 475 | +it("logs polling startup diagnostics without using the error channel", async () => { |
| 476 | +const runtime = { |
| 477 | +log: vi.fn(), |
| 478 | +error: vi.fn(), |
| 479 | +exit: vi.fn(), |
| 480 | +}; |
| 481 | + |
| 482 | +await monitorWithAutoAbort({ runtime }); |
| 483 | + |
| 484 | +expect(runtime.log).toHaveBeenCalledWith(expect.stringContaining("polling cycle started")); |
| 485 | +expect(runtime.error).not.toHaveBeenCalled(); |
| 486 | +}); |
| 487 | + |
| 488 | +it("keeps polling restart warnings on the error channel", async () => { |
| 489 | +const abort = new AbortController(); |
| 490 | +const runtime = { |
| 491 | +log: vi.fn(), |
| 492 | +error: vi.fn(), |
| 493 | +exit: vi.fn(), |
| 494 | +}; |
| 495 | +const firstCycle = mockRunOnceWithStalledPollingRunner(); |
| 496 | +const secondCycle = mockRunOnceAndAbort(abort); |
| 497 | + |
| 498 | +const monitor = monitorTelegramProvider( |
| 499 | +withLegacyPolling({ token: "tok", abortSignal: abort.signal, runtime }), |
| 500 | +); |
| 501 | +await firstCycle.waitForTaskStart(); |
| 502 | + |
| 503 | +expect(emitUnhandledRejection(await makeTaggedPollingFetchError())).toBe(true); |
| 504 | +await secondCycle.waitForRunStart(); |
| 505 | +await monitor; |
| 506 | + |
| 507 | +expect(runtime.log).toHaveBeenCalledWith( |
| 508 | +"[telegram][diag] marking transport dirty after polling network failure", |
| 509 | +); |
| 510 | +expect(runtime.error).toHaveBeenCalledWith( |
| 511 | +expect.stringContaining("Restarting polling after unhandled network error"), |
| 512 | +); |
| 513 | +}); |
| 514 | + |
475 | 515 | it("requires mention in groups by default", async () => { |
476 | 516 | for (const v of Object.values(api)) { |
477 | 517 | if (typeof v === "function" && "mockReset" in v) { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -108,7 +108,15 @@ async function loadTelegramMonitorWebhookRuntime() {
|
108 | 108 | } |
109 | 109 | |
110 | 110 | export async function monitorTelegramProvider(opts: MonitorTelegramOpts = {}) { |
111 | | -const log = opts.runtime?.error ?? console.error; |
| 111 | +const logInfo = (line: string) => (opts.runtime?.log ?? console.log)(line); |
| 112 | +const logError = (line: string) => (opts.runtime?.error ?? console.error)(line); |
| 113 | +const log = (line: string) => { |
| 114 | +if (line.includes("[telegram][diag]")) { |
| 115 | +logInfo(line); |
| 116 | +return; |
| 117 | +} |
| 118 | +logError(line); |
| 119 | +}; |
112 | 120 | let pollingSession: TelegramPollingSessionInstance | undefined; |
113 | 121 | |
114 | 122 | const handlePollingNetworkFailure = (err: unknown, label: string) => { |
@@ -231,7 +239,7 @@ export async function monitorTelegramProvider(opts: MonitorTelegramOpts = {}) {
|
231 | 239 | try { |
232 | 240 | await deleteTelegramUpdateOffset({ accountId: account.accountId }); |
233 | 241 | } catch (err) { |
234 | | -(opts.runtime?.error ?? console.error)( |
| 242 | +logError( |
235 | 243 | `telegram: failed to delete stale update offset after rotation: ${String(err)}`, |
236 | 244 | ); |
237 | 245 | } |
@@ -261,9 +269,7 @@ export async function monitorTelegramProvider(opts: MonitorTelegramOpts = {}) {
|
261 | 269 | botToken: token, |
262 | 270 | }); |
263 | 271 | } catch (err) { |
264 | | -(opts.runtime?.error ?? console.error)( |
265 | | -`telegram: failed to persist update offset: ${String(err)}`, |
266 | | -); |
| 272 | +logError(`telegram: failed to persist update offset: ${String(err)}`); |
267 | 273 | } |
268 | 274 | }; |
269 | 275 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。