From 38b2bef2ec6fd6c7aee7292a7069728b799e25a1 Mon Sep 17 00:00:00 2001 From: Bashy Date: Sun, 22 Nov 2026 16:34:57 +0200 Subject: [PATCH] Fix: a Custom Power-up crashed the server (activity log without event type) alerts.js named redeem alerts for the log from a map without custom_power_up, so logActivity got event_type undefined -> SQLite NOT NULL error -> uncaught -> the process exited (the video alert never reached the overlay). Add custom_power_up, fall back to a generic type, and never let a failed activity-log write crash the server. Co-Authored-By: Claude Opus 5.5 --- src/alerts.js | 4 ++-- src/dispatch.js | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/alerts.js b/src/alerts.js index b24ac56..fc062cd 100644 --- a/src/alerts.js +++ b/src/alerts.js @@ -22,8 +22,8 @@ function legacy(alert) { case 'streak': return ['watch_streak', String(alert.streak)]; case 'hype': return ['hype_train', alert.phase]; case 'tip': return ['tip', `${alert.amount} ${alert.currency}`]; - case 'redeem': return [{ reward: 'channel_points', auto_reward: 'auto_reward', power_up: 'power_up' }[alert.kind], alert.key]; - default: return [alert.type, null]; + case 'redeem': return [{ reward: 'channel_points', auto_reward: 'auto_reward', power_up: 'power_up', custom_power_up: 'custom_power_up' }[alert.kind] || 'redeem', alert.key]; + default: return [alert.type || 'alert', null]; } } diff --git a/src/dispatch.js b/src/dispatch.js index 41fa79e..4b22c8e 100644 --- a/src/dispatch.js +++ b/src/dispatch.js @@ -32,7 +32,9 @@ function dispatchEvent(eventType, eventDetail = null, username = null, data = nu console.log(`[dispatch] Fired action ${action.id} (${action.name}) — event: ${eventType}, user: ${username}`); } - db.logActivity(eventType, eventDetail, username, data, fired, replay); + // the log must never take the server down (a bad row once crashed it mid-stream) + try { db.logActivity(eventType || 'unknown', eventDetail, username, data, fired, replay); } + catch (e) { console.error(`[dispatch] activity log failed (${eventType}):`, e.message); } } module.exports = { dispatchEvent };