Skip to content

[Bug]: Gateway crashes into infinite restart loop due to Unhandled Promise Rejection on LLM API failure #23441

Description

@windowslhh

Summary

When the LLM API call fails (e.g., due to an unauthorized model or 404/403 error), an Unhandled Promise Rejection occurs. This crashes the entire OpenClaw Node.js gateway process instantly, often leaving zombie processes that cause infinite restart loops.

Steps to reproduce

  1. Set up a system prompt or boot sequence that forces the agent to send a message immediately upon a new session.
  2. Switch to a model that the current API Key does NOT have permission to access (e.g., switching to gemini-2-flash without the proper Google API scope).
  3. Trigger /new or the boot sequence.
  4. The API call fails, throwing an Unhandled Promise Rejection.
  5. The entire OpenClaw gateway crashes and attempts to restart, hitting a port conflict/zombie process loop.

Expected behavior

The core engine should wrap LLM API calls in a try/catch block or properly handle the Promise rejection. If an API call fails, it should:

  1. Log the error cleanly.
  2. Gracefully degrade or send a fallback [System Error: Model API failed] message to the chat.
  3. Keep the gateway process alive instead of crashing.

Actual behavior

The gateway process exits immediately with an UnhandledPromiseRejectionWarning or fatal error.
The port remains occupied by a zombie process.
The process manager (or systemd) attempts to restart the gateway.
The new process fails to bind to the port (EADDRINUSE), leading to an infinite crash loop until manually killed.
The chat interface stops responding completely.

OpenClaw version

v 2026.02.22

Operating system

Ubuntu 24.04

Install method

npm globle

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstaleMarked 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