diff --git a/CHANGELOG.md b/CHANGELOG.md index 90a60ddd8..a366e9828 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ ### Fixes - Heartbeat replies now strip repeated `HEARTBEAT_OK` tails to avoid accidental “OK OK” spam. +- Heartbeat failure logs now include the error reason instead of `[object Object]`. - Duration strings now accept `h` (hours) where durations are parsed (e.g., heartbeat intervals). - WhatsApp send now preserves existing JIDs (including group `@g.us`) instead of coercing to `@s.whatsapp.net`. (Thanks @arun-8687.) - Telegram/WhatsApp: reply context stays in `Body`/`ReplyTo*`, but outbound replies no longer thread to the original message. (Thanks @joshp123 for the PR and follow-up question.) diff --git a/src/infra/heartbeat-runner.ts b/src/infra/heartbeat-runner.ts index 53b7f3f6e..dc0045c1d 100644 --- a/src/infra/heartbeat-runner.ts +++ b/src/infra/heartbeat-runner.ts @@ -11,6 +11,7 @@ import { saveSessionStore, type SessionEntry, } from "../config/sessions.js"; +import { formatErrorMessage } from "../infra/errors.js"; import { createSubsystemLogger } from "../logging.js"; import { getQueueSize } from "../process/command-queue.js"; import { defaultRuntime, type RuntimeEnv } from "../runtime.js"; @@ -367,13 +368,14 @@ export async function runHeartbeatOnce(opts: { }); return { status: "ran", durationMs: Date.now() - startedAt }; } catch (err) { + const reason = formatErrorMessage(err); emitHeartbeatEvent({ status: "failed", - reason: String(err), + reason, durationMs: Date.now() - startedAt, }); - log.error("heartbeat failed", { error: String(err) }); - return { status: "failed", reason: String(err) }; + log.error(`heartbeat failed: ${reason}`, { error: reason }); + return { status: "failed", reason }; } }