Skip to content

fix: [memos-local-plugin] Dreaming background processing starves Gateway event loop, causing WebSocket timeouts #1808

@tianxin8206

Description

@tianxin8206

Pre-submission checklist | 提交前检查

  • I have searched existing issues and this hasn't been mentioned before | 我已搜索现有问题,确认此问题尚未被提及
  • I have read the project documentation and confirmed this issue doesn't already exist | 我已阅读项目文档并确认此问题尚未存在
  • This issue is specific to MemOS and not a general software issue | 该问题是针对 MemOS 的,而不是一般软件问题

Bug Description | 问题描述

The memos-local-plugin's "dreaming" feature performs LLM inference calls synchronously on the Gateway's main Node.js event loop. When processing orphan or dirty episodes, this blocks the event loop for extended periods (observed eventLoopMax of 3.5s+), causing WebSocket handshake timeouts for OpenClaw TUI and Control UI connections.

How to Reproduce | 如何重现

Steps to Reproduce

  1. Enable memos-local-plugin with dreaming enabled
  2. Accumulate a large number of episodes (30K+ traces in our case)
  3. Have one or more episodes enter an orphan/dirty state (e.g., r_task = NULL)
  4. Restart the openclaw gateway
  5. Attempt to connect via TUI or Control UI during dreaming processing

Observed Behavior

  • OpenClaw Gateway event loop blocked for 3-5+ seconds during dreaming LLM calls
  • WebSocket upgrade requests timeout (default 3s budget for read probe)
  • TUI reports "cannot connect to gateway"
  • Control UI login page fails to load
  • Gateway logs show repeated Read probe: failed - timeout errors
  • Orphan episodes with failed LLM calls are retried indefinitely with no backoff

Environment | 环境信息

  • OpenClaw version: 2026.5.22
  • OS: openeuler (systemd user service)
  • memos.db size: 324MB, 30K+ traces
  • Model provider: DeepSeek (v4-flash for dreaming)

Additional Context | 其他信息

No response

Willingness to Implement | 实现意愿

  • I'm willing to implement this myself | 我愿意自己解决
  • I would like someone else to implement this | 我希望其他人来解决

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpendingPending items to be addressed | 待解决事项。pluginPlugin/adapter/bridge layer (apps/ directory)

    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