openclaw - 💡(How to fix) Fix control-ui sessions.list polling saturates gateway with many conversations [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#57974Fetched 2026-04-08 01:55:25
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Participants

Root Cause

Two open tabs (overview + chat) produce ~24 calls/minute, keeping the gateway at 100% CPU permanently. This blocks other operations — agent spawns time out at 10 seconds because the gateway cannot service them between sessions.list responses.

Code Example

sessions.list 4799ms conn=96c962a9…a738
sessions.list 4783ms conn=96c962a9…a738
sessions.list 4786ms conn=e6d28eb7…db0c
sessions.list 4780ms conn=96c962a9…a738
sessions.list 4765ms conn=e6d28eb7…db0c
RAW_BUFFERClick to expand / collapse

Bug

Version: v2026.3.28

Problem

The openclaw-control-ui webchat client polls sessions.list every ~5-7 seconds per connected tab. With a large LCM database (~5,000 conversations, 163K messages), each sessions.list call takes ~4.8 seconds to resolve.

Two open tabs (overview + chat) produce ~24 calls/minute, keeping the gateway at 100% CPU permanently. This blocks other operations — agent spawns time out at 10 seconds because the gateway cannot service them between sessions.list responses.

Observed Impact

  • Gateway pegged at 100% CPU, 3.8 GB RSS
  • sessions.spawn calls timeout (10s) — unable to run concurrent sub-agents
  • Previously could run 10 parallel agents; now struggles with 2
  • Closing both webchat tabs immediately dropped CPU to ~20%

Gateway log evidence

sessions.list 4799ms conn=96c962a9…a738
sessions.list 4783ms conn=96c962a9…a738
sessions.list 4786ms conn=e6d28eb7…db0c
sessions.list 4780ms conn=96c962a9…a738
sessions.list 4765ms conn=e6d28eb7…db0c

Two connections (96c962a9 = overview tab, e6d28eb7 = chat tab), both identified as openclaw-control-ui webchat v2026.3.28.

Root Causes

  1. No pagination/caching on sessions.list — appears to do a full scan of all conversations every call. 4.8s is too slow regardless of polling frequency.
  2. Aggressive polling interval — ~5s per tab with no backoff, no document.hidden check, no debouncing across multiple tabs.

Suggested Fixes

Server-side:

  • Cache sessions.list results (TTL 10-30s) — session list changes rarely
  • Add pagination support (offset/limit)
  • Consider a lightweight /sessions/summary endpoint that returns counts + last-active without full enumeration

Client-side:

  • Increase polling interval to 15-30s (sessions change slowly)
  • Pause polling when tab is not visible (document.visibilitychange)
  • Deduplicate across tabs (SharedWorker, BroadcastChannel, or localStorage lock)
  • Use exponential backoff if response time exceeds threshold

Environment

  • macOS (arm64), Node v22.22.1
  • LCM DB: 1.0 GB, 5,082 conversations, 163,059 messages, 1,204 depth-0 summaries
  • Gateway bound to loopback (127.0.0.1:18789)

extent analysis

Fix Plan

To address the issue, we will implement the following fixes:

Server-side:

  1. Cache sessions.list results: Implement a caching mechanism with a TTL of 10-30 seconds.
  2. Add pagination support: Introduce offset and limit parameters to the sessions.list endpoint.
  3. Create a lightweight /sessions/summary endpoint: Return counts and last-active information without full enumeration.

Client-side:

  1. Increase polling interval: Update the polling interval to 15-30 seconds.
  2. Pause polling when tab is not visible: Use the document.visibilitychange event to pause polling.
  3. Deduplicate across tabs: Utilize a SharedWorker, BroadcastChannel, or localStorage lock to deduplicate requests.
  4. Implement exponential backoff: Increase the polling interval if the response time exceeds a threshold.

Example Code

Server-side (Node.js)

const express = require('express');
const app = express();
const cache = require('memory-cache');

// Cache sessions.list results for 10 seconds
app.get('/sessions.list', (req, res) => {
  const cachedResult = cache.get('sessionsList');
  if (cachedResult) {
    return res.json(cachedResult);
  }

  // Fetch sessions list from database
  const sessions = fetchSessionsFromDatabase();
  cache.put('sessionsList', sessions, 10000); // 10 seconds
  res.json(sessions);
});

// Add pagination support
app.get('/sessions.list', (req, res) => {
  const offset = req.query.offset;
  const limit = req.query.limit;
  const sessions = fetchSessionsFromDatabase(offset, limit);
  res.json(sessions);
});

// Create a lightweight /sessions/summary endpoint
app.get('/sessions/summary', (req, res) => {
  const summary = fetchSummaryFromDatabase();
  res.json(summary);
});

Client-side (JavaScript)

// Increase polling interval to 15 seconds
const pollingInterval = 15000;

// Pause polling when tab is not visible
document.addEventListener('visibilitychange', () => {
  if (document.visibilityState === 'hidden') {
    // Pause polling
  } else {
    // Resume polling
  }
});

// Deduplicate across tabs using localStorage
const storage = window.localStorage;
const lockKey = 'sessionsListLock';

// Implement exponential backoff
let backoffInterval = pollingInterval;
function pollSessionsList() {
  fetch('/sessions.list')
    .then((response) => {
      if (response.ok) {
        backoffInterval = pollingInterval;
      } else {
        backoffInterval *= 2;
      }
    })
    .catch((error) => {
      backoffInterval *= 2;
    });
  setTimeout(pollSessionsList, backoffInterval);
}

Verification

To verify the

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 control-ui sessions.list polling saturates gateway with many conversations [1 participants]