Skip to content

Discord: Reaction listeners registered unconditionally even when all guilds have reactionNotifications=off #47516

Description

@x4v13r1120

Summary

Reaction event listeners (DiscordReactionListener, DiscordReactionRemoveListener) are always registered regardless of guild configuration. When all guilds have reactionNotifications: "off", reaction events still hit the event queue, go through guild config resolution and authorization checks, then return early. This triggers Slow listener detected warnings and contributes to event queue congestion.

Environment

  • OpenClaw: 2026.3.13 (61d171a)
  • OS: Windows 11 (x64)
  • Node: v22.22.0
  • Discord with 2 guilds, both reactionNotifications: "off"
  • 28 active sessions

Root Cause

In dist/discord-CcCLMjHw.js (line ~139651), reaction listeners are registered unconditionally:

registerDiscordListener(client.listeners, new DiscordReactionListener(reactionListenerOptions));
registerDiscordListener(client.listeners, new DiscordReactionRemoveListener(reactionListenerOptions));

Even though the handler checks reactionMode === "off" and returns early, the listener is still registered on the EventEmitter, processes the event through the queue, resolves guild info, and triggers slow listener detection before bailing.

Impact

  • Slow listener detected warnings on every reaction event
  • Event queue congestion when many reactions happen (e.g., multi-agent Discord servers where bots react to each other)
  • Unnecessary processing overhead

Suggested Fix

Skip listener registration when all configured guilds have reactionNotifications: "off":

const allGuildsReactionsOff = guildEntries && 
  Object.keys(guildEntries).length > 0 && 
  Object.values(guildEntries).every(g => g.reactionNotifications === "off");

if (!allGuildsReactionsOff) {
  registerDiscordListener(client.listeners, new DiscordReactionListener(reactionListenerOptions));
  registerDiscordListener(client.listeners, new DiscordReactionRemoveListener(reactionListenerOptions));
}

This is the patch I applied locally and it resolved the slow listener warnings immediately.

Workaround

Manually patch the dist file as shown above. Gets overwritten on update.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions