Skip to content

RPC agent crashes (unhandled process exit) on a single null input line #141

Open

Description

@dangzitou

What happened?
A single line containing just null on stdin kills the whole RPC agent with an unhandled rejection, instead of returning an error response. Every other malformed line ([], 123, {}, "hi") is handled fine — only valid-JSON null is fatal:

$ printf 'null\n' | step --mode rpc
TypeError: Cannot read properties of null (reading 'id')
    at handleInputLine (...)
Node.js v22.23.2      <- process exits

One bad line (from a client that emits a half-written frame, or any upstream producer) tears down the running session/daemon.

Steps to reproduce

  1. printf 'null\n' | step --mode rpc
  2. Process exits non-zero with the TypeError above; it should stay up.

Root cause: packages/coding-agent/src/modes/rpc/rpc-mode.ts handleInputLine casts the parsed payload to RpcCommand and reads command.id in both handleCommand and the catch. On null the first read throws, then the catch reads command.id again and re-throws, escaping as an unhandled rejection.

Expected behavior
Emit an error response frame for that line and keep serving subsequent commands.

Version
0.84.4

I'd like to implement the fix myself.

Activity

  1. github-actions commented on Sep 22, 2026

    @github-actions

    This issue was auto-closed. All issues from new contributors are auto-closed by default.

    Maintainers review auto-closed issues daily and reopen worthwhile ones. Issues that do not meet the quality bar in CONTRIBUTING.md will not be reopened or receive a reply.

    If a maintainer replies lgtmi on one of your issues, your future issues will stay open. If a maintainer replies lgtm, your future issues and PRs will stay open. The command must be at the start of the reply (optionally after one or more @username mentions) or at the end.

    See CONTRIBUTING.md.

  2. added a commit that references this issue on Sep 24, 2026
    dee0e99
  3. dangzitou commented on Sep 24, 2026

    @dangzitou
    Author

    Follow-up: the fix is ready and now rebased onto current main. The original PR #142 was auto-closed minutes after opening by the contributor gate, which has since been removed from main (#152).

    Branch: dangzitou/Step-Code → fix/rpc-null-line-crash @ dee0e99 — a single commit, 11 lines in packages/coding-agent/src/modes/rpc/rpc-mode.ts. It guards null / non-object parsed payloads before the RpcCommand cast and emits the same error response frame other malformed input already produces, so a lone null line can no longer kill the RPC agent. Verified on current main with the existing RPC suites and the exact repro from this issue (before: uncaught TypeError, non-zero exit; after: error frame, exit 0 on stdin EOF). The bug is still present on main.

    I can't land it myself right now:

    If the branch looks right, could someone open the PR from it, or let me know how you'd like to proceed? Happy to adjust the message shape or squash it.

  4. added 2 commits that reference this issue on Sep 24, 2026
    756982f
    e773a7a
  5. li-xiu-qi commented on Oct 26, 2026

    @li-xiu-qi
    Collaborator

    I’ll pick this up from @dangzitou’s unmerged fix in #142. I’ve reproduced the crash on current main and verified the guard with sequential and same-chunk JSONL inputs, plus the real RPC process. I’m consolidating the commits and doing a final diff review before reopening #308.

  6. self-assigned this
    on Oct 26, 2026
  7. added 2 commits that reference this issue on Oct 26, 2026
    a8c4638
    169b426
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions