openclaw - ✅(Solved) Fix gateway restart loop: notifyActiveTaskWaiters crashes with 'TypeError: undefined is not iterable' [1 pull requests, 1 comments, 2 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#61730Fetched 2026-04-08 02:55:18
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×2commented ×1subscribed ×1

On macOS, openclaw-gateway enters a restart loop because notifyActiveTaskWaiters() throws:

TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))

This causes the gateway to disconnect repeatedly.

Error Message

TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
    at Array.from (<anonymous>)
    at notifyActiveTaskWaiters (file:///Users/mini/.npm-global/lib/node_modules/openclaw/dist/command-queue-Cssp02gj.js:88:29)
    at file:///Users/mini/.npm-global/lib/node_modules/openclaw/dist/command-queue-Cssp02gj.js:136:8

Root Cause

On macOS, openclaw-gateway enters a restart loop because notifyActiveTaskWaiters() throws:

Fix Action

Fix / Workaround

Temporary Local Mitigation

After that patch, the gateway stopped immediately crashing and remained up long enough to process inbound WeCom traffic normally.

Is this a known issue in 2026.4.5? If not, I can help provide a more minimal repro or test a candidate patch.

PR fix notes

PR #61732: fix: repair corrupted command queue singleton state

Description (problem / solution / changelog)

Summary

  • repair the shared command queue singleton when top-level fields are corrupted instead of crashing the gateway
  • rebuild invalid activeTaskWaiters / lanes containers and normalize primitive state in getQueueState()
  • add a regression test covering a corrupted global singleton before waitForActiveTasks() drains active work

Testing

  • pnpm vitest run src/process/command-queue.test.ts
  • pnpm exec oxlint src/process/command-queue.ts src/process/command-queue.test.ts

Closes #61730

Changed files

  • src/process/command-queue.test.ts (modified, +35/-0)
  • src/process/command-queue.ts (modified, +35/-3)

Code Example

TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))

---

[diagnostic] lane task error: lane=main durationMs=...
[openclaw] Unhandled promise rejection: TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
    at Array.from (<anonymous>)
    at notifyActiveTaskWaiters (file:///.../command-queue-Cssp02gj.js:88:29)
    at file:///.../command-queue-Cssp02gj.js:136:8
[gateway] loading configuration…
[gateway] ready (...)

---

TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
    at Array.from (<anonymous>)
    at notifyActiveTaskWaiters (file:///Users/mini/.npm-global/lib/node_modules/openclaw/dist/command-queue-Cssp02gj.js:88:29)
    at file:///Users/mini/.npm-global/lib/node_modules/openclaw/dist/command-queue-Cssp02gj.js:136:8

---

for (const waiter of Array.from(queueState.activeTaskWaiters)) { ... }

---

const activeTaskWaiters =
  queueState.activeTaskWaiters instanceof Set
    ? queueState.activeTaskWaiters
    : (queueState.activeTaskWaiters = new Set());
RAW_BUFFERClick to expand / collapse

Summary

On macOS, openclaw-gateway enters a restart loop because notifyActiveTaskWaiters() throws:

TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))

This causes the gateway to disconnect repeatedly.

Version

  • OpenClaw: 2026.4.5
  • Runtime: Node 25.6.1
  • OS: macOS

Symptom

The gateway appears to come up normally, then crashes and restarts every ~20-40 seconds.

Observed log pattern:

[diagnostic] lane task error: lane=main durationMs=...
[openclaw] Unhandled promise rejection: TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
    at Array.from (<anonymous>)
    at notifyActiveTaskWaiters (file:///.../command-queue-Cssp02gj.js:88:29)
    at file:///.../command-queue-Cssp02gj.js:136:8
[gateway] loading configuration…
[gateway] ready (...)

Stack Trace

TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
    at Array.from (<anonymous>)
    at notifyActiveTaskWaiters (file:///Users/mini/.npm-global/lib/node_modules/openclaw/dist/command-queue-Cssp02gj.js:88:29)
    at file:///Users/mini/.npm-global/lib/node_modules/openclaw/dist/command-queue-Cssp02gj.js:136:8

What I already checked

  • This is not only an auth/token mismatch issue.
  • I initially saw older openclaw-tui clients reconnecting with token mismatch, but after clearing those, the restart loop still continued.
  • I marked stale running sessions as done in:
    • ~/.openclaw/agents/main/sessions/sessions.json
  • After that, there were no remaining obvious stuck running sessions, but the gateway still restarted.

Likely Root Cause

notifyActiveTaskWaiters() assumes queueState.activeTaskWaiters is iterable:

for (const waiter of Array.from(queueState.activeTaskWaiters)) { ... }

In my case, queueState.activeTaskWaiters appears to become invalid/corrupted at runtime, so Array.from(...) itself throws before waiter validation can even run.

This looks like a command-queue / restart / task-drain lifecycle bug rather than a channel-specific problem.

Temporary Local Mitigation

I added a local guard in command-queue-Cssp02gj.js to rebuild activeTaskWaiters if it is no longer a Set, and to drop malformed waiter entries.

Conceptually:

const activeTaskWaiters =
  queueState.activeTaskWaiters instanceof Set
    ? queueState.activeTaskWaiters
    : (queueState.activeTaskWaiters = new Set());

After that patch, the gateway stopped immediately crashing and remained up long enough to process inbound WeCom traffic normally.

Why I think this is related to restart/task lifecycle

I noticed recent release notes mention fixes in nearby areas:

  • gateway reload / restart loop behavior
  • task registry maintenance affecting gateway event loop
  • interrupted session wake after restart

So this may be another bug in the same lifecycle surface.

Environment Details

  • launchd service: ai.openclaw.gateway
  • install path:
    • /Users/mini/.npm-global/lib/node_modules/openclaw/dist/command-queue-Cssp02gj.js

Additional Info

I can also provide:

  • the relevant sessions.json state before cleanup
  • the repeating gateway log window
  • confirmation that a defensive guard around activeTaskWaiters stops the restart loop

Question

Is this a known issue in 2026.4.5? If not, I can help provide a more minimal repro or test a candidate patch.

extent analysis

TL;DR

Adding a local guard to rebuild activeTaskWaiters if it becomes invalid can prevent the gateway restart loop.

Guidance

  • Verify that queueState.activeTaskWaiters is indeed becoming corrupted or invalid at runtime by adding logging or debugging statements around the notifyActiveTaskWaiters() function.
  • Apply the temporary local mitigation by adding a guard to rebuild activeTaskWaiters if it is no longer a Set, as described in the issue.
  • Investigate recent release notes and nearby areas of the codebase to determine if this issue is related to fixes in gateway reload/restart loop behavior or task registry maintenance.
  • Consider providing a minimal repro or testing a candidate patch to further diagnose and resolve the issue.

Example

const activeTaskWaiters =
  queueState.activeTaskWaiters instanceof Set
    ? queueState.activeTaskWaiters
    : (queueState.activeTaskWaiters = new Set());

Notes

The provided temporary local mitigation appears to be a viable workaround, but it may not address the underlying cause of the issue. Further investigation and testing are needed to determine the root cause and develop a more permanent fix.

Recommendation

Apply the workaround by adding a defensive guard around activeTaskWaiters to prevent the restart loop, as it has been shown to be effective in stopping the immediate crashing of the gateway.

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 - ✅(Solved) Fix gateway restart loop: notifyActiveTaskWaiters crashes with 'TypeError: undefined is not iterable' [1 pull requests, 1 comments, 2 participants]