[BUG] `--resume` with empty prompt (`-p ""`) causes unhandled promise rejection and zombie process

Resolved 💬 3 comments Opened Dec 31, 2025 by wehriam Closed Feb 27, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When using Claude Code CLI with --resume SESSION_ID -p "" (resuming a session with an empty prompt in print mode), the CLI throws an unhandled promise rejection with "Error: No messages returned" but does not exit. The process continues running indefinitely in a zombie state, consuming resources and blocking automated workflows.

What Should Happen?

Either:

  • Option A: Reject the empty prompt with a clear error message and exit with non-zero code
  • Option B: Handle the empty prompt gracefully (perhaps as a no-op that exits cleanly)

Error Messages/Logs

$ claude --resume 77e97828-9138-4cb9-b57f-fdbe1407a5d1 -p ""

This error originated either by throwing inside of an async function without a catch block,
or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error: No messages returned
    at nD9 (file:///usr/local/share/npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:4886:73)
    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)

# Process does NOT exit - hangs indefinitely until killed


## Output from reproduce-no-messages-returned.sh


================================================================
CLAUDE CODE BUG REPRODUCTION
================================================================
[2025-12-31T12:30:02-05:00] Bug: 'Error: No messages returned' with --resume -p ""
[2025-12-31T12:30:02-05:00] Date: 2025-12-31T12:30:02-05:00
[2025-12-31T12:30:02-05:00] Log file: /workspace/documentation/229-debug/reproduction-20251231-123002.log
[2025-12-31T12:30:02-05:00] 

================================================================
ENVIRONMENT
================================================================
[2025-12-31T12:30:03-05:00] Claude version: 2.0.76 (Claude Code)
[2025-12-31T12:30:03-05:00] Node version: v24.11.1
[2025-12-31T12:30:03-05:00] Platform: Linux 6.12.54-linuxkit
[2025-12-31T12:30:03-05:00] Shell: /bin/zsh
[2025-12-31T12:30:03-05:00] Working directory: /workspace
[2025-12-31T12:30:03-05:00] Using provided session ID: 77e97828-9138-4cb9-b57f-fdbe1407a5d1

================================================================
REPRODUCTION ATTEMPT
================================================================
[2025-12-31T12:30:03-05:00] Session ID: 77e97828-9138-4cb9-b57f-fdbe1407a5d1
[2025-12-31T12:30:03-05:00] Command: claude --resume 77e97828-9138-4cb9-b57f-fdbe1407a5d1 -p ""
[2025-12-31T12:30:03-05:00] 
[2025-12-31T12:30:03-05:00] Expected behavior: Claude should either:
[2025-12-31T12:30:03-05:00]   a) Reject the empty prompt with a clear error and exit, OR
[2025-12-31T12:30:03-05:00]   b) Handle the empty prompt gracefully
[2025-12-31T12:30:03-05:00] 
[2025-12-31T12:30:03-05:00] Actual behavior: Claude throws unhandled promise rejection but
[2025-12-31T12:30:03-05:00]                  does NOT exit - process becomes a zombie
[2025-12-31T12:30:03-05:00] 
[2025-12-31T12:30:03-05:00] Starting reproduction (30 second timeout)...
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error: No messages returned
    at nD9 (file:///usr/local/share/npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:4886:73)
    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
[2025-12-31T12:30:33-05:00] 

================================================================
RESULTS
================================================================
[2025-12-31T12:30:33-05:00] Exit code: 124
[2025-12-31T12:30:33-05:00] Duration: 30s
[2025-12-31T12:30:33-05:00] ^[[0;31mTIMEOUT: Process did not exit within 30 seconds^[[0m
[2025-12-31T12:30:33-05:00] ^[[0;31mThis confirms the zombie state bug - process hangs indefinitely^[[0m

Steps to Reproduce

  1. Create a session:

``bash
claude -p "Say hello" --output-format json
# Note the session_id from the output
``

  1. Attempt to resume with an empty prompt:

``bash
claude --resume <SESSION_ID> -p ""
``

  1. Observe the error and process behavior

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.0.76

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

VS Code integrated terminal

Additional Information

Process State After Error

$ ps -p <PID> -o pid,stat,wchan
  PID STAT WCHAN
12345 Sl   do_epo    # Sleeping in epoll_wait - event loop still running

$ cat /proc/<PID>/status | grep State
State:  S (sleeping)
Threads: 11

Environment

  • Claude Code version: 2.0.76
  • Node.js: v24.11.1
  • Platform: Linux 6.12.54-linuxkit (Docker/WSL2), also reproducible on macOS
  • Installation: npm global (npm install -g @anthropic-ai/claude-code)

Impact

This bug impacts automated workflows that:

  1. Resume sessions programmatically - Any automation that resumes sessions without guaranteed non-empty prompts will hang
  2. Use wrapper scripts - Parent processes waiting for Claude to exit will wait forever
  3. Run in CI/CD pipelines - Pipelines will timeout instead of failing fast
  4. Manage multiple concurrent sessions - Zombie processes accumulate, exhausting resources

Suggested Fixes

Immediate (Input Validation)

// Before processing, validate prompt in print mode
if (options.printMode && (!prompt || prompt.trim() === '')) {
  console.error('Error: Print mode (-p) requires a non-empty prompt');
  process.exit(1);
}

reproduce-no-messages-returned.sh

Workaround

Ensure prompts are never empty when using -p with --resume:

# Instead of:
claude --resume $SESSION_ID -p ""

# Use:
claude --resume $SESSION_ID -p "Continue."

Reproduction Script

See attached reproduce-no-messages-returned.sh which:

  1. Creates a test session
  2. Attempts to reproduce the bug
  3. Logs all output and confirms the zombie state

Root Cause Analysis

The error originates from print mode output validation in cli.js:

  1. --resume loads the existing session transcript
  2. -p "" (empty prompt) adds no new user message to the conversation
  3. The conversation loop completes with no new assistant response
  4. Print mode validation expects a result to output
  5. With no result, it throws Error: No messages returned
  6. The error is an unhandled promise rejection
  7. Node.js logs the error but continues running (default behavior without --unhandled-rejections=strict)
  8. Active handles (sockets, timers) keep the event loop alive

Related Issues

  • This is distinct from #9936 "No assistant message found" (different error, different cause)
  • This is distinct from #10007 which was marked as duplicate of #9936

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗