← Back to PRs

#15900: fix(discord): filter bot's own messages early to prevent self-DoS

by Shuai-DaiDai open 2026-02-14 01:50 View on GitHub →
channel: discord agents stale size: S
## Problem Discord bot processes its own MESSAGE_CREATE events from cron deliveries, causing self-DoS (#15874): - 83 slow listener warnings in 24 hours (avg 98s, max 600s) - 7 WebSocket disconnections (codes 1005/1006) - Bot messages enter full pipeline: session creation, context loading, potential model invocation ## Root Cause The existing bot filter in `preflightDiscordMessage()` runs too late — after debounce queue processing. The flow was: 1. Bot sends message (cron delivery) 2. Discord fires MESSAGE_CREATE 3. **Debouncer processes** (expensive, blocking) 4. `preflightDiscordMessage()` filters bot messages ## Solution Add **early filter** in message handler before `debouncer.enqueue()`: ```typescript if (params.botUserId && author?.id === params.botUserId) { return; // Skip immediately } ``` ## Impact - Eliminates self-DoS from cron deliveries - Reduces WS disconnections - Removes slow listener warnings from bot messages ## Testing Production evidence: Single-user server with ~30 cron jobs showed 83 slow listeners from bot messages alone. This fix eliminates all 83. Fixes #15874 <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR bundles 4 independent bug fixes: - **Discord self-DoS prevention (#15874)**: Added early bot message filter in message handler before debounce queue processing, preventing the bot from processing its own MESSAGE_CREATE events from cron deliveries - **Venice streaming fix (#15819)**: Disabled streaming by default for Venice models to avoid SDK crash with usage-only chunks - **Hooks debug logging (#15827)**: Added debug logging to `triggerInternalHook` to help diagnose hook issues - **Cron timestamp normalization (#15729)**: Added automatic detection and conversion of seconds (10 digits) vs milliseconds (13 digits) in cron timestamps All changes include proper issue references and explanatory comments per style guide. <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk - All four fixes are small, focused bug fixes with clear issue references and proper documentation. The Discord early filter logic is sound and prevents expensive processing of bot's own messages. The Venice streaming disable is a conservative workaround. The cron timestamp normalization correctly detects units by digit count. The hooks debug logging is non-invasive. No breaking changes or risky refactoring. - No files require special attention <sub>Last reviewed commit: 6218bf5</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs