Skip to content

[2026.4.26] Gateway main thread stalls under orchestration load; /readyz timeouts and reload deferred behind active runs #73467

Closed

Description

@cygnostik

Summary

On OpenClaw 2026.4.26, the gateway intermittently stalls under active orchestration / multi-agent workload. During stalls, the gateway PID remains alive, but local /readyz probes time out and the main Node/OpenClaw gateway thread is CPU-hot while the host is otherwise mostly idle.

This presents externally as Discord/app-command failures, delayed /status output, dropped typing indicators, and delayed agent coordination, but the captured evidence points to gateway/control-plane starvation rather than a Discord-only issue.

Environment

  • OpenClaw: 2026.4.26
  • Runtime: Node 24.x
  • OS: Linux, systemd user service
  • Gateway: local loopback on 127.0.0.1:18789
  • Channel surface involved: Discord DM-only, WebUI/WS, local /readyz
  • Plugins: memory-lancedb-pro present with auto-recall/smart extraction enabled
  • Host had ample RAM; system CPU was mostly idle during captured stalls

Sensitive paths, tokens, hostnames, and private config values are intentionally omitted/redacted.

Observed behavior

Captured multiple stall windows where:

  • curl --max-time 2 http://127.0.0.1:18789/readyz timed out locally
  • gateway PID stayed alive
  • top -H showed the main OpenClaw/Node gateway thread at ~99.9% CPU
  • overall host CPU stayed mostly idle, usually ~97-98% idle
  • RSS was around 1.4-1.5 GB, not host memory pressure
  • other V8/libuv/tokio worker threads were mostly sleeping

Representative packet excerpts:

LOOPSTALL_PACKET count=1 trigger_ts=2026-04-28T01:34:44-07:00 pid=229097 readyz=000 2.002326curlfail cpu=34.2 rss_kb=1464220 nlwp=47
Threads:  47 total,   1 running,  46 sleeping,   0 stopped,   0 zombie
%Cpu(s):  1.6 us,  0.7 sy,  0.0 ni, 97.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
 229097 argus     20   0   23.8g   1.4g 110144 R  99.9   0.6   8:55.89 opencla+
LOOPSTALL_PACKET count=3 trigger_ts=2026-04-28T01:34:57-07:00 pid=229097 readyz=000 2.002098curlfail cpu=34.6 rss_kb=1466852 nlwp=47
Threads:  47 total,   1 running,  46 sleeping,   0 stopped,   0 zombie
%Cpu(s):  2.0 us,  0.8 sy,  0.0 ni, 97.2 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
 229097 argus     20   0   23.8g   1.4g 110144 R  99.9   0.6   9:08.90 opencla+
LOOPSTALL_PACKET_WAIT count=2 trigger_ts=2026-04-28T01:37:29-07:00 pid=229097 readyz=000 2.002292curlfail cpu=38.3 rss_kb=1544108 nlwp=75
Threads:  75 total,   1 running,  74 sleeping,   0 stopped,   0 zombie
%Cpu(s):  1.3 us,  0.1 sy,  0.0 ni, 98.5 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
 229097 argus     20   0   23.8g   1.5g 110144 R  99.9   0.6   9:54.53 opencla+

During the same broader incident, reload/restart remained deferred for more than 9 minutes behind active bookkeeping:

2026-04-28T01:56:41-07:00 [reload] restart still deferred after 426856ms with 3 task run(s) active
2026-04-28T01:57:29-07:00 [reload] restart still deferred after 474798ms with 2 operation(s), 1 reply(ies), 1 embedded run(s), 3 task run(s) active
2026-04-28T01:57:59-07:00 [reload] restart still deferred after 505189ms with 2 operation(s), 1 reply(ies), 1 embedded run(s), 3 task run(s) active
2026-04-28T01:58:30-07:00 [reload] restart still deferred after 535678ms with 2 operation(s), 1 reply(ies), 1 embedded run(s), 3 task run(s) active
2026-04-28T01:59:00-07:00 [reload] restart still deferred after 566110ms with 3 task run(s) active

Adjacent plugin/memory activity was present, but I do not have enough evidence to say it is the root cause. Example adjacent lines:

2026-04-28T01:57:30-07:00 [plugins] memory-lancedb-pro: auto-recall query truncated from 6874 to 1000 chars
2026-04-28T01:57:32-07:00 [plugins] memory-lancedb-pro: strict governance filtered all candidates; using relaxed fallback recall (...)
2026-04-28T01:57:45-07:00 [plugins] memory-lancedb-pro: auto-recall timed out after 15000ms; skipping memory injection to avoid stalling agent startup
2026-04-28T01:58:05-07:00 [plugins] memory-lancedb-pro: injecting 2 memories into context for agent argus
2026-04-28T01:58:54-07:00 [plugins] memory-lancedb-pro: smart-extracted 1 created, 1 merged, 2 skipped for agent argus

User-visible effects during these windows:

  • Discord /status returned an application failure, then stale status output was delivered much later after a newer user message
  • Discord typing indicators paused/dropped
  • WebUI/WS operations such as sessions.list and chat.history became delayed or bunched after stalls
  • reload/config changes did not apply while restart remained deferred behind active run bookkeeping
  • orchestration became unsafe because corrective messages and status checks could be delayed/stale

Expected behavior

  • /readyz should remain responsive, or return a degraded status, even during long agent/plugin/model work.
  • Discord/app-command/control-plane traffic should not be blocked by a single CPU-hot gateway event-loop path.
  • Deferred reload/restart should not remain blocked indefinitely by stale reply/embedded/task-run accounting.
  • Long-running plugin hooks or recall work should be bounded/offloaded so they cannot starve gateway control paths.
  • If active runs block reload, there should be an inspectable source of truth and a safe timeout/reaper path.

Why this looks gateway/control-plane related

This is not just Discord channel flakiness:

  • the local /readyz endpoint missed on loopback while the process was alive
  • the main gateway thread was running at ~99.9% CPU during misses
  • the host was mostly idle and not RAM constrained
  • reload/restart bookkeeping reported active reply/embedded/task runs for many minutes
  • stale /status output was later delivered after the user had moved on

Related / possibly relevant issues

This looks distinct from, but likely related to, prior gateway/event-loop/resource issues:

The case here is specifically 2026.4.26 gateway runtime behavior: local /readyz stalls + main gateway thread CPU spin + deferred reload behind active run accounting.

What would help

  • Recommended way to capture a V8/Node CPU profile or event-loop delay trace from a live gateway during a stall
  • Built-in gateway event-loop lag diagnostics exposed in logs or /readyz
  • A hard timeout/reaper for stale active reply / embedded run / task-run accounting
  • A way to inspect active reply/embedded/task-run blockers directly
  • Guidance on whether plugin before_prompt_build hooks can block the gateway event loop
  • A safe way to force reload/restart after a grace period without waiting indefinitely on stale task bookkeeping

Notes

I can provide more redacted packet/log excerpts if useful. I avoided attaching full logs because the original environment contains secrets and private channel/session details.

Activity

  1. clawsweeper commented on Apr 28, 2026

    @clawsweeper
    Contributor

    Thanks for the context here. I did a careful shell check against current main, and this is already implemented.

    Current main and v2026.6.6 cover the reported 2026.4.26 failure cluster with bounded restart deferral, task-blocker diagnostics/recovery, readiness event-loop health, and logs --follow reconnect behavior; broader control-plane separation remains tracked separately.

    So I’m closing this as already implemented rather than keeping a duplicate issue open.

    Review details

    Best possible solution:

    Keep the shipped v2026.6.6 gateway stability fixes, use #42026 for future control-plane/runtime separation, and ask for a fresh current-version diagnostic export if the same symptom recurs.

    Do we have a high-confidence way to reproduce the issue?

    Yes for the affected 2026.4.26 release: the report gives concrete loopback /readyz timeouts, CPU-hot main-thread samples, reload-deferral logs, and logs --follow disconnect output. I did not reproduce the old release live during this read-only review, and current main now has targeted source fixes for those paths.

    Is this the best way to solve the issue?

    Yes. The implemented path is the maintainable fix for this report: bound reload deferral, expose event-loop health in readiness, recover interrupted sessions, and make log following reconnect, while leaving the larger distributed-runtime architecture to #42026.

    Security review:

    Security review: This is non-PR issue cleanup with no patch security or supply-chain surface to review.

    AGENTS.md: found and applied where relevant.

    What I checked:

    • Source: bounded restart deferral shipped in release: v2026.6.6 has DEFAULT_RESTART_DEFERRAL_TIMEOUT_MS = 300_000, so omitted gateway.reload.deferralTimeoutMs no longer waits indefinitely. (src/infra/restart.ts:25, 8c802aa68351)
    • Source: reload timeout forces restart with blocker details: v2026.6.6 defers config-triggered restarts only until resolveGatewayRestartDeferralTimeoutMs(...) expires, then logs remaining blockers and forces the restart. (src/gateway/server-reload-handlers.ts:574, 8c802aa68351)
    • Source: /readyz event-loop health diagnostics: Current readiness carries event-loop degradation, delay, utilization, and CPU-core-ratio data into detailed local or authenticated readiness responses. (src/gateway/server/event-loop-health.ts:18, 8c802aa68351)
    • Source: logs --follow transient reconnect loop: v2026.6.6 retries transient logs --follow transport failures with bounded backoff and reports reconnect notices instead of immediately exiting. (src/cli/logs-cli.ts:328, 8c802aa68351)
    • Test coverage: forced restart after active task timeout: The gateway reload test proves active background task blockers are logged, timeout emits a forced restart intent, and active main sessions are marked for restart recovery. (src/gateway/server-reload-handlers.test.ts:720, b5999bc6a07d)
    • Test coverage: readiness includes event-loop health: The readiness test asserts detailed readiness includes an eventLoop block without changing readiness state. (src/gateway/server/readiness.test.ts:303, b5999bc6a07d)

    Likely related people:

    • vincentkoc: GitHub commit metadata credits Vincent Koc for the bounded restart deferral and readiness event-loop health fixes that directly cover this report's reload and /readyz asks. (role: gateway restart/readiness fix author; confidence: high; commits: 1f41b8b44ba0, 75ba8398f939, b85edb3f0cf6; files: src/infra/restart.ts, src/gateway/server-reload-handlers.ts, src/gateway/server/event-loop-health.ts)
    • joshavant: The merged restart-recovery PR marks interrupted main sessions before forced restarts, which is adjacent to the stale active-run accounting described here. (role: restart recovery contributor; confidence: high; commits: 99a269f8b4f3, 0680d22b8880, ac09d8a6a065; files: src/agents/main-session-restart-recovery.ts, src/gateway/server-reload-handlers.ts, src/cli/gateway-cli/run-loop.test.ts)
    • shashank-poola: The merged logs-follow PR implements bounded retries for transient gateway disconnects, covering the operator observability symptom added in the issue comments. (role: logs follow reconnect contributor; confidence: medium; commits: 23fe3559e5a2, d8cb97e24ee6, 64babc30eed9; files: src/cli/logs-cli.ts, src/cli/logs-cli.test.ts, docs/cli/logs.md)
    • RomneyDa: The follow-up merged PR added reconnect notices and JSON-mode parity for the logs-follow recovery path. (role: logs follow UX follow-up contributor; confidence: medium; commits: 4bb4127a33bf, 7269c9fec86e; files: src/cli/logs-cli.ts, src/cli/logs-cli.test.ts, docs/cli/logs.md)

    Codex review notes: model internal, reasoning high; reviewed against b5999bc6a07d; fix evidence: release v2026.6.6, commit 8c802aa68351.

  2. cygnostik commented on Apr 28, 2026

    @cygnostik
    ContributorAuthor

    Additional follow-up from the same host after a controlled supervisor restart:

    1. The deferred restart condition persisted for roughly 125 minutes before SIGTERM/supervisor restart cleared it.
    03:49:01 [reload] restart still deferred after 7166912ms with 3 task run(s) active
    03:54:37 [reload] restart still deferred after 7502528ms with 3 task run(s) active
    03:54:49 [gateway] signal SIGTERM received
    03:54:50 [gateway] restart mode: full process restart (supervisor restart)
    

    After restart, the previously staged config change was picked up, confirming that the pending reload had been blocked by the active task accounting:

    03:55:22 memory-lancedb-pro: smart extraction enabled (LLM model: gpt-5.4-mini, timeoutMs: 20000, noise bank: ON)
    
    1. On the first fresh-boot reply, the user-visible reply completed quickly, but the control/log-follow path still dropped during the reply startup window:
    04:00:20 [gateway/ws] closed before connect ... code=1006
    04:00:20 [discord] Gateway reconnect scheduled ... (invalid-session, resume=false)
    04:00:23 [plugins] memory-lancedb-pro: strict governance filtered all candidates; using relaxed fallback recall (...)
    04:00:25 [plugins] memory-lancedb-pro: injecting 2 memories into context for agent argus
    04:00:26 [gateway/ws] sessions.list 664ms
    04:00:26 [gateway/ws] chat.history 815ms
    04:00:43-04:00:47 memory smart-extractor ran after the response
    

    So the restart/config application helped the first reply complete, but the control-plane/log-follow connection still appears fragile around reply startup. The long-lived stale 3 task run(s) active blocker remains the strongest lifecycle/accounting issue from this incident.

  3. cygnostik commented on Apr 28, 2026

    @cygnostik
    ContributorAuthor

    One more concrete user-facing symptom that may deserve separate handling:

    openclaw logs --follow is being dumped back to the shell during agent reply / memory work. This happens over local loopback while the gateway process remains up and the agent reply may still complete.

    Example from the operator shell immediately after a reply/memory-extraction window:

    04:00:47-07:00 info plugins {"subsystem":"plugins"} memory-pro: smart-extractor: created [events] ...
    04:00:47-07:00 info plugins {"subsystem":"plugins"} memory-lancedb-pro: smart-extracted 1 created, 0 merged, 2 skipped for agent argus
    gateway connect failed: Error: gateway closed (1000):
    Gateway not reachable. Is it running and accessible?
    Gateway target: ws://127.0.0.1:18789
    Source: local loopback
    Config: /home/argus/.openclaw/openclaw.json
    Bind: loopback
    Hint: run `openclaw doctor`.
    argus@typhon:~/.openclaw$
    

    This is arguably the most direct operational problem: the local observability/control path exits exactly during the failure window, so the operator loses logs --follow when it is most needed.

    Expected behavior: openclaw logs --follow should treat normal gateway WS close/reload/backpressure/startup churn as reconnectable, or at least stay in a reconnecting/resubscribing state with clear status, rather than exiting to the shell and saying the gateway is not reachable while the gateway/reply may still be active.

    This may be a separate logs --follow resilience issue, but I am adding it here because it appears tightly coupled to the gateway/control-plane stalls described above.

  4. openclaw-barnacle commented on May 30, 2026

    @openclaw-barnacle

    This issue has been automatically marked as stale due to inactivity.
    Please add updates or it will be closed.

  5. added
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:crash-loopCrash, hang, restart loop, or process-level availability failure.
    impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.
    impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.
    on Jun 14, 2026
  6. locked as resolved and limited conversation to collaborators on Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.staleMarked as stale due to inactivity

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions