openclaw - 💡(How to fix) Fix Gateway crashes with 'Agent listener invoked outside active run' unhandled promise rejection [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#62362Fetched 2026-04-08 03:05:28
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Timeline (top)
cross-referenced ×1

Gateway crashes repeatedly with unhandled promise rejection: Error: Agent listener invoked outside active run

Error Message

2026-04-07T16:15:16.611+09:00 [openclaw] Unhandled promise rejection: Error: Agent listener invoked outside active run systemd[1738]: openclaw-gateway.service: Main process exited, code=exited, status=1/FAILURE

2026-04-07T16:21:51.997+09:00 [openclaw] Unhandled promise rejection: Error: Agent listener invoked outside active run systemd[1738]: openclaw-gateway.service: Main process exited, code=exited, status=1/FAILURE

2026-04-07T16:25:29.599+09:00 [openclaw] Unhandled promise rejection: Error: Agent listener invoked outside active run systemd[1738]: openclaw-gateway.service: Main process exited, code=exited, status=1/FAILURE

2026-04-07T16:30:08.344+09:00 [openclaw] Unhandled promise rejection: Error: Agent listener invoked outside active run systemd[1738]: openclaw-gateway.service: Main process exited, code=exited, status=1/FAILURE

Root Cause

Gateway crashes repeatedly with unhandled promise rejection: Error: Agent listener invoked outside active run

Code Example

2026-04-07T16:15:16.611+09:00 [openclaw] Unhandled promise rejection: Error: Agent listener invoked outside active run
systemd[1738]: openclaw-gateway.service: Main process exited, code=exited, status=1/FAILURE

2026-04-07T16:21:51.997+09:00 [openclaw] Unhandled promise rejection: Error: Agent listener invoked outside active run
systemd[1738]: openclaw-gateway.service: Main process exited, code=exited, status=1/FAILURE

2026-04-07T16:25:29.599+09:00 [openclaw] Unhandled promise rejection: Error: Agent listener invoked outside active run
systemd[1738]: openclaw-gateway.service: Main process exited, code=exited, status=1/FAILURE

2026-04-07T16:30:08.344+09:00 [openclaw] Unhandled promise rejection: Error: Agent listener invoked outside active run
systemd[1738]: openclaw-gateway.service: Main process exited, code=exited, status=1/FAILURE
RAW_BUFFERClick to expand / collapse

Description

Gateway crashes repeatedly with unhandled promise rejection: Error: Agent listener invoked outside active run

Frequency

Multiple crashes in short period (3+ times within ~15 minutes on 2026-04-07)

Environment

  • OpenClaw: 2026.4.5 (3e72c03)
  • Node.js: v22.22.2
  • OS: Ubuntu 24.04 (Linux 6.8.0-106-generic)
  • Platform: Linux desktop

Error Logs

2026-04-07T16:15:16.611+09:00 [openclaw] Unhandled promise rejection: Error: Agent listener invoked outside active run
systemd[1738]: openclaw-gateway.service: Main process exited, code=exited, status=1/FAILURE

2026-04-07T16:21:51.997+09:00 [openclaw] Unhandled promise rejection: Error: Agent listener invoked outside active run
systemd[1738]: openclaw-gateway.service: Main process exited, code=exited, status=1/FAILURE

2026-04-07T16:25:29.599+09:00 [openclaw] Unhandled promise rejection: Error: Agent listener invoked outside active run
systemd[1738]: openclaw-gateway.service: Main process exited, code=exited, status=1/FAILURE

2026-04-07T16:30:08.344+09:00 [openclaw] Unhandled promise rejection: Error: Agent listener invoked outside active run
systemd[1738]: openclaw-gateway.service: Main process exited, code=exited, status=1/FAILURE

Additional Context

  • This crash also causes secondary issues with Discord channels (stale-socket restarts) and MCP server failures
  • n8n MCP server shows Error: spawn enhanced-n8n-mcp-server ENOENT after crash (binary link broken but fixed separately)
  • The error seems to occur during agent execution - possibly when multiple exec commands are sent rapidly

Expected Behavior

Gateway should handle this error gracefully without crashing

extent analysis

TL;DR

The gateway crashes can be mitigated by handling promise rejections properly, potentially by catching and handling the Error: Agent listener invoked outside active run exception.

Guidance

  • Investigate the agent execution code to identify where the Error: Agent listener invoked outside active run exception is being thrown and ensure it is properly caught and handled.
  • Review the code for any potential race conditions that may be causing the agent listener to be invoked outside of an active run.
  • Consider implementing a retry mechanism for agent executions that fail due to this error, to prevent cascading failures.
  • Verify that the openclaw version 2026.4.5 is the latest available, as this issue may be resolved in a newer version.

Example

// Example of catching and handling the promise rejection
agent.execute(command)
 .catch((error) => {
    if (error.message === 'Agent listener invoked outside active run') {
      // Handle the error, e.g., retry the execution or log the error
      console.error('Agent listener invoked outside active run:', error);
    } else {
      throw error;
    }
  });

Notes

The provided information suggests that the issue is related to the agent execution code, but without more context or code snippets, it's difficult to provide a more specific solution. Additionally, the openclaw version and Node.js version may be relevant to the issue, but without more information, it's unclear if upgrading or downgrading would resolve the issue.

Recommendation

Apply workaround: Implement proper error handling for the Error: Agent listener invoked outside active run exception to prevent the gateway from crashing. This will allow the system to continue functioning, even if the underlying issue is not fully resolved.

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