From e6ce1717f00309cc9a4948dc0dfad6b36ea180a5 Mon Sep 17 00:00:00 2001 From: Robby Date: Wed, 17 Jun 2026 12:48:48 +0200 Subject: [PATCH] fix: add onWarn callback to BusClient.connect() in getBus() #159 --- src/status.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/status.ts b/src/status.ts index b508300..b8dee4a 100644 --- a/src/status.ts +++ b/src/status.ts @@ -95,7 +95,27 @@ export function initStatus(client: PluginInput["client"], directory: string): vo function getBus(): Promise { if (!_busPromise) { - _busPromise = BusClient.connect().catch((err) => { + _busPromise = BusClient.connect({ + onWarn: (msg, ...args) => { + const details = args + .map((a) => { + try { + return typeof a === "object" && a !== null ? JSON.stringify(a) : String(a); + } catch { + return "[unserializable]"; + } + }) + .join(" "); + _client?.app?.log({ + body: { + service: "brain", + level: "warn", + message: msg, + extra: { details }, + }, + }).catch(() => {}); + }, + }).catch((err) => { _client?.app?.log({ body: { service: "brain", level: "warn", message: "BusClient connect failed", extra: { error: String(err) } } }).catch(() => {}); _busPromise = null; // allow retry on next call throw err;