openvibers/openvibe.live Commits

PowerChat: make chat-relay failures visible

OP OpenVibers committed 18 Aug 2026 · 2912841488 · 1 file, +27 −1

forwardChat() ended in `catch { /* silent */ }`, so a broken overlay relay was
indistinguishable from a working one — there was no way to confirm whether the
channel-scope fix actually landed messages on the overlay, or whether a scope or
rate-limit problem was quietly dropping them.

Log the first failure per streamer and then at most one a minute, plus a line
when it recovers. Quiet while healthy, so a busy chat does not produce a log
line per message.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xw6Sf5zzSALw8m93XNu5JE

Changes

ddiff --git a/server/integrations/powerchat-platform.js b/server/integrations/powerchat-platform.js
iindex 2d1b4cc5..ed716e7f 100644
---- a/server/integrations/powerchat-platform.js
++++ b/server/integrations/powerchat-platform.js
@@@ -80,7 +80,33 @@ async function forwardChat(streamerUserId, { chatterName, externalChatterId, mes
...(isModerator ? { isModerator: true } : {}),
},
});
-- } catch { /* scope/sandbox/rate — silent */ }
++ _relayOk(streamerUserId);
++ } catch (e) {
++ // This used to be silently swallowed, which meant a broken overlay relay looked
++ // exactly like a working one. Log the first failure and then at most one per
++ // minute per streamer, so a persistent problem is visible without flooding a
++ // busy chat with one line per message.
++ _relayFail(streamerUserId, e && e.message);
++ }
++}
++
++// Relay health: quiet on success, but surface failures at a sane rate.
++const _relayState = new Map(); // userId → { failAt, okAfterFail }
++function _relayOk(userId) {
++ const st = _relayState.get(userId);
++ if (st && st.failAt) {
++ console.log(`[PowerChat] chat relay recovered for user ${userId}`);
++ _relayState.delete(userId);
++ }
++}
++function _relayFail(userId, reason) {
++ const now = Date.now();
++ const st = _relayState.get(userId) || { failAt: 0 };
++ if (now - st.failAt > 60000) {
++ console.warn(`[PowerChat] chat relay failed for user ${userId}: ${reason || 'unknown'}`);
++ st.failAt = now;
++ _relayState.set(userId, st);
++ }
}
// ── follows:write ────────────────────────────────────────────