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 <noreply@anthropic.com>
This commit is contained in:
parent
a32a55c264
commit
38b2bef2ec
2 changed files with 5 additions and 3 deletions
|
|
@ -22,8 +22,8 @@ function legacy(alert) {
|
||||||
case 'streak': return ['watch_streak', String(alert.streak)];
|
case 'streak': return ['watch_streak', String(alert.streak)];
|
||||||
case 'hype': return ['hype_train', alert.phase];
|
case 'hype': return ['hype_train', alert.phase];
|
||||||
case 'tip': return ['tip', `${alert.amount} ${alert.currency}`];
|
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];
|
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, null];
|
default: return [alert.type || 'alert', null];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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}`);
|
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 };
|
module.exports = { dispatchEvent };
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue