OpenClaw 4.5 notifyActiveTaskWaiters TypeError crashes Discord gateway
A TypeError in command-queue.ts notifyActiveTaskWaiters crashes the Discord gateway handler when processing incoming messages, causing all messages to be silently dropped.
🔍 Symptoms
Primary Manifestation
The Discord gateway crashes with a TypeError upon receiving any incoming message. The bot becomes completely non-responsive with no replies sent.
Error Output
TypeError: undefined is not iterable (cannot read property 'length' of undefined)
at notifyActiveTaskWaiters (command-queue.ts)
→ Gateway handler crashes before any reply can be sent
→ All Discord messages silently dropped
Behavioral Symptoms
- Bot accepts the WebSocket connection successfully
- No acknowledgment of received messages in logs
- Discord shows no bot response to user messages
- Gateway connection remains active but idle
- Other plugin functionality may be affected depending on command queue usage
Environment
- OpenClaw Version: 2026.4.5
- Node.js: v22.22.1
- OS: Linux (Ubuntu)
- Channel: Discord
🧠 Root Cause
Direct Cause
The notifyActiveTaskWaiters function in command-queue.ts receives an undefined value where it expects an iterable array. The function attempts to access the .length property or iterate over this value without a guard clause, triggering the TypeError.
Failure Sequence
- User sends a message to the Discord bot
- Gateway receives the message payload via WebSocket
- Gateway handler invokes
notifyActiveTaskWaiters notifyActiveTaskWaitersreceivesundefinedinstead of an array- Internal iteration or length check fails on
undefined - TypeError propagates up the call stack
- Gateway handler crashes without processing the message
Contributing Configuration Issues
During diagnosis, secondary configuration problems were identified that compound the issue:
- Malformed config nesting: Configuration was nested/duplicated inside itself with a malformed
"cha"key, indicating corruptedconfig.yml - Removed legacy key:
channels.discord.guilds.<id>.channels.<id>.allowwas removed in OpenClaw 4.5 but still present in the config - Missing plugin declarations:
discordandanthropicplugins were absent fromplugins.allow - Stale plugin reference:
browserexisted inplugins.allowreferencing a plugin removed in a prior version
Architectural Context
The command queue system manages async task coordination between the gateway and plugin execution. In version 4.5, a code change introduced a dependency on an array that may not always be populated under certain configuration states, particularly when plugin declarations are incomplete or legacy keys conflict with the new schema.
🛠️ Step-by-Step Fix
Immediate Workaround: Rollback (Recommended for Production)
If immediate Discord functionality is required:
# Roll back to last known stable version
npm install [email protected]
# Restart the gateway
openclaw restartPermanent Fix: Configuration Remediation
Execute the built-in diagnostic and repair tool:
openclaw doctor --fixThis command automatically addresses:
- Corrupted or nested configuration structures
- Legacy keys removed in version 4.5
- Missing plugin declarations
- Stale plugin references
Manual Configuration Repair (if doctor fails)
Step 1: Backup current config
cp config.yml config.yml.backup-$(date +%Y%m%d)Step 2: Remove legacy channel allow keys
Locate and remove all instances of:
channels:
discord:
guilds:
<guild-id>:
channels:
<channel-id>:
allow: [...] # REMOVE THIS KEY COMPLETELYStep 3: Fix plugins.allow section
Replace your plugins.allow block with the correct plugin list:
# Before (broken)
plugins:
allow:
- browser # STALE - remove this
# Missing: discord, anthropic
# After (correct)
plugins:
allow:
- discord
- anthropic
# Add other active plugins as neededStep 4: Validate configuration structure
openclaw config validateStep 5: Restart gateway
openclaw restartAfter Fix: Verify Plugin Declaration
openclaw plugins list --enabledConfirm that discord appears in the enabled plugins list.
🧪 Verification
Step 1: Confirm Config Validity
openclaw config validateExpected output:
✓ Configuration schema validated
✓ No legacy keys detected
✓ Plugin declarations completeStep 2: Run Diagnostic Tool
openclaw doctorExpected output (no errors):
Checking configuration... OK
Checking plugin declarations... OK
Checking Discord gateway connectivity... OK
No issues found.Step 3: Verify Gateway Connection
openclaw status --channel discordExpected output:
Discord Gateway: CONNECTED
Bot User: <your-bot-name>
Latency: <value>msStep 4: Functional Test
Send a test message to the bot in Discord. Verify:
- Message is received and logged in gateway output
- Bot responds within expected latency
- No TypeError appears in gateway logs
Step 5: Check Logs for Errors
openclaw logs --tail 100 --level errorExpected: No TypeError: undefined is not iterable entries.
Step 6: Verify Command Queue Stability
Send multiple rapid messages to confirm the command queue handles concurrent requests:
# Send 5 messages in rapid succession
for i in {1..5}; do
echo "Test message $i" | openclaw send --channel test-channel
doneAll messages should be processed without crashes.
⚠️ Common Pitfalls
Configuration Corruption
- Duplicate/nested config: Manually editing
config.ymlcan introduce nested copies. Always useopenclaw config setfor programmatic updates. - YAML indentation: Incorrect indentation breaks parsing. Use spaces (not tabs) for indentation.
- Special characters: Unquoted strings containing
:, #, {, }can cause parse errors.
Plugin Management
- Plugin not in allow list: Even if installed, a plugin will not load unless explicitly listed in
plugins.allow. - Removed plugins: Plugins removed in prior versions (like
browser) may persist in config and cause validation failures. - Order sensitivity: Some plugins have dependencies. Ensure dependent plugins are declared after their dependencies.
Version-Specific Traps
- Skipping versions: Upgrading directly from 4.3 to 4.5 may miss migration steps. Use sequential upgrades for complex version jumps.
- Lock file drift:
package-lock.jsonmay cache the broken version. Delete lock file before reinstalling.
Environment-Specific Issues
- Docker: Ensure volume mounts persist config between container restarts. Check that
openclaw doctor --fixwrites to the correct mounted volume. - pm2/systemd: Service managers may cache old process state. Restart the service, not just the process.
- Windows: Line ending differences (
\r\nvs\n) can corrupt YAML. Ensure consistent line endings inconfig.yml.
Migration Gotchas
- Channel allow keys: Version 4.5 removed per-channel allow rules. Migrate any existing rules to the new permission system before upgrading.
- Plugin config keys: Some plugin-specific keys were renamed. Check the 4.5 changelog for deprecated key mappings.
🔗 Related Errors
TypeError: undefined is not iterable (cannot read property ’length’ of undefined)
- Location:
notifyActiveTaskWaitersincommand-queue.ts - Trigger: Gateway processes incoming Discord message
- Related: Issue #4521 - Command queue assumes always-array input
Configuration Schema Validation Failures
- Error:
ConfigValidationError: Unknown key 'channels.*.channels.*.allow' - Trigger: Loading config with legacy channel allow keys
- Related: Breaking changes in OpenClaw 4.5 plugin system
Plugin Load Failures
- Error:
PluginNotFoundError: Plugin 'browser' not found in registry - Trigger: Stale plugin reference in
plugins.allow - Related: Plugin registry cleanup in v4.4+
Gateway WebSocket Disconnection
- Error:
GatewayError: WebSocket closed with code 1006 - Trigger: Unhandled exception in gateway handler
- Related: Cascading failure from TypeError in message processing
Configuration Nesting Corruption
- Error:
YAMLSyntaxError: Nested mappings are not allowed - Trigger: Malformed YAML with duplicate keys or incorrect nesting
- Related: Manual config editing errors, failed programmatic updates