Skip to content

Gateway crashes with unhandled write EPIPE when CodexAppServerClient receives unparseable stdout #67886

@kai-the-man

Description

@kai-the-man

Environment

  • Version: 2026.4.15
  • OS: Linux
  • Install Method: script

Description

The CodexAppServerClient communicates with the codex-acp subprocess over stdio. If the subprocess encounters an initialization failure (for instance, an interactive prompt emitted to stdout, or a deprecated config file throwing an error string), the subprocess writes plaintext text to stdout and then abruptly exits.

Currently, CodexAppServerClient.handleLine attempts to JSON.parse() this stdout text, fails, and catches the parsing error. When the child process exits immediately after (closing its pipe), OpenClaw subsequently attempts to write the JSON-RPC initialize payload to the deceased subprocess's stdin. Because no error listener is attached to the stdin stream, Node.js throws an unhandled write EPIPE exception, which cascades to immediately terminate the entire OpenClaw gateway daemon.

Expected Behavior

A misconfigured or failing child plugin subprocess should fail gracefully without taking down the entire OpenClaw gateway daemon.

Proposed Fix

Attach an error event handler to child.stdin to swallow expected pipe lifecycle tear-down errors:

if (child.stdin) {
    child.stdin.on('error', (err) => {
        if (err.code !== 'EPIPE') {
            log.debug('codex app-server stdin error', { err });
        }
    });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions