openclaw - 💡(How to fix) Fix Feature: configurable staleEventThresholdMs for channel health monitor [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#52717Fetched 2026-04-08 01:19:58
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Participants

Root Cause

In gateway-cli-*.js, resolveTimingPolicy() falls back to 18e5 (30min) when deps.timing?.staleEventThresholdMs is undefined. The main health monitor call site (startChannelHealthMonitor()) only passes channelManager and checkIntervalMs — no timing object.

Code Example

{
  "gateway": {
    "channelHealthCheckMinutes": 5,
    "channelHealthMonitor": {
      "staleEventThresholdMs": 7200000
    }
  }
}
RAW_BUFFERClick to expand / collapse

Problem

The WhatsApp channel health monitor restarts the socket when no events arrive for >30 minutes (staleEventThresholdMs defaults to 1,800,000ms). During idle periods (e.g., nighttime), this causes ~38 unnecessary socket restarts per day.

Root Cause

In gateway-cli-*.js, resolveTimingPolicy() falls back to 18e5 (30min) when deps.timing?.staleEventThresholdMs is undefined. The main health monitor call site (startChannelHealthMonitor()) only passes channelManager and checkIntervalMs — no timing object.

Impact

  • ~38 restarts/day (1-2/hour), evenly distributed
  • 0 message delivery failures observed (restarts are seamless, 2-5s reconnect)
  • Cosmetic log noise, unnecessary reconnection churn

Requested Change

Expose staleEventThresholdMs as a configurable option, e.g.:

{
  "gateway": {
    "channelHealthCheckMinutes": 5,
    "channelHealthMonitor": {
      "staleEventThresholdMs": 7200000
    }
  }
}

Suggested default: 2 hours (7,200,000ms) for long-socket channels like WhatsApp.

Environment

  • OpenClaw 2026.3.13
  • WhatsApp channel (Baileys/WWebJS)
  • Ubuntu 24.04 LTS

extent analysis

Fix Plan

To fix the issue, we need to expose staleEventThresholdMs as a configurable option.

Step-by-Step Solution

  1. Update configuration: Add staleEventThresholdMs to the configuration file:
{
  "gateway": {
    "channelHealthCheckMinutes": 5,
    "channelHealthMonitor": {
      "staleEventThresholdMs": 7200000
    }
  }
}
  1. Modify resolveTimingPolicy(): Update gateway-cli-*.js to use the configured staleEventThresholdMs value:
function resolveTimingPolicy(deps) {
  // ...
  const staleEventThresholdMs = deps.timing?.staleEventThresholdMs || 7200000; // default to 2 hours
  // ...
}
  1. Pass timing object to startChannelHealthMonitor(): Update the startChannelHealthMonitor() call site to pass the timing object:
startChannelHealthMonitor(channelManager, checkIntervalMs, {
  staleEventThresholdMs: 7200000, // or use the configured value
});

Verification

To verify the fix, monitor the logs for unnecessary socket restarts during idle periods. The number of restarts should decrease significantly.

Extra Tips

  • Make sure to update the default value of staleEventThresholdMs to 2 hours (7,200,000ms) for long-socket channels like WhatsApp.
  • Consider adding logging to track the number of socket restarts and the reason for each restart.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Feature: configurable staleEventThresholdMs for channel health monitor [1 participants]