Skip to content

[Bug] Discord plugin fetch timeout blocks Node.js event loop, causing liveness warnings #77634

@guguangxin-eng

Description

@guguangxin-eng

Bug Description

The Discord plugin's HTTP fetch calls to https://discord.com/api/v10/users/@me are causing the Node.js event loop to block for extended periods (3+ seconds), resulting in severe liveness warning alerts.

Environment

  • OpenClaw version: 2026.5.3-1
  • Node.js version: 24.15.0
  • Platform: Windows_NT 10.0.26100 (x64)
  • Host: GGX-THINKPAD

Steps to Reproduce

  1. Enable Discord channel plugin (channels.discord.enabled: true)
  2. Gateway starts and connects to Discord API
  3. Observe liveness warnings in logs immediately

Observed Behavior

Log excerpt:

[fetch-timeout] fetch timeout after 2500ms (elapsed 3013ms) operation=fetchWithTimeout url=https://discord.com/api/v10/users/@Me [diagnostic] liveness warning: reasons=event_loop_delay interval=30s eventLoopDelayP99Ms=35.3 eventLoopDelayMaxMs=1362.1 eventLoopUtilization=0.096 cpuCoreRatio=0.093

Key observations:

  1. Direct Node.js fetch test is FAST: etch('https://discord.com/api/v10/users/@me', {headers:{Authorization:'Bot ...'}}) returns in ~600ms — completely normal
  2. Direct curl test is FAST: ~232ms
  3. The etchWithTimeout wrapper in the Discord plugin causes blocking: The AbortController timeout mechanism itself appears to block the event loop for the full timeout duration (2500ms + overhead = 3013ms)
  4. Timer is delayed: The timeout fired at 3013ms instead of 2500ms, indicating the timer was itself blocked by ~513ms
  5. Low CPU utilization during block: Only 23% CPU — this is I/O wait, not computation

Root Cause Hypothesis

The etchWithTimeout from openclaw/plugin-sdk/text-runtime uses setTimeout wrapped around an AbortController-based fetch. When the fetch is in flight, something in the Node.js 24.x fetch/undici implementation or the plugin-sdk's getResolvedFetch appears to block the event loop synchronously during DNS/TLS/hot connection reuse, causing the timeout timer itself to be delayed.

The Discord plugin probe at dist/probe-DmHUl6wI.js calls:
js const res = await fetchWithTimeout(${DISCORD_API_BASE}/users/@me, { headers: { Authorization: Bot } }, timeoutMs, getResolvedFetch(fetcher));

Impact

  • Gateway event loop blocks for 3+ seconds during Discord API probe
  • Causes severe liveness warning with eventLoopDelayMaxMs up to 5440ms
  • Affects overall gateway responsiveness

Suggested Fix Directions

  1. Investigate whether getResolvedFetch(fetcher) returns a different fetch implementation that behaves synchronously under Node.js 24.x
  2. Consider using a non-blocking timeout approach (e.g., separate worker thread for Discord API calls)
  3. Increase the timeout from 2500ms to something more generous, or make it configurable
  4. Add retry logic with exponential backoff instead of blocking the main thread

Tags

bug, discord, event-loop, node.js-24, performance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions