#15900: fix(discord): filter bot's own messages early to prevent self-DoS
channel: discord
agents
stale
size: S
Cluster:
Signal and Discord Fixes
## 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
#21463: fix(discord): prevent WebSocket death spiral + fix numeric channel ID…
by akropp · 2026-02-20
80.9%
#17254: fix(discord): intercept text-based slash commands instead of forwar...
by robbyczgw-cla · 2026-02-15
79.5%
#16801: fix: Register Discord listeners before gateway connects
by MisterGuy420 · 2026-02-15
79.2%
#20009: fix(discord): immediately defer interactions to prevent timeouts
by Gitjay11 · 2026-02-18
78.2%
#20913: fix: intercept Discord embed images to enforce mediaMaxMb
by MumuTW · 2026-02-19
78.0%
#17316: fix: ack reaction not removed when block streaming is enabled (Tele...
by czmathew · 2026-02-15
77.4%
#23158: discord: harden preflight/reply path against slow lookup latency
by danielstarman · 2026-02-22
77.2%
#22611: fix(discord): allow messages from other instance bots in multi-acco...
by dae-sun · 2026-02-21
76.8%
#13430: fix(discord): properly handle bot-sent @everyone mentions
by wassimbensalem · 2026-02-10
76.5%
#7719: fix(slack): thread replies with @mentions dropped in requireMention...
by SocialNerd42069 · 2026-02-03
76.5%