[BUG] Claude crashes with unhandled promise rejection
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?
- claude --print with -p flag crashes with unhandled promise rejection: Error: No messages returned
- Process hangs indefinitely after the error instead of exiting with a non-zero code
- stderr output:
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 lEB (/$bunfs/root/claude:5989:78)
What Should Happen?
Claude should execute a prompt and at least crash with a log
Error Messages/Logs
- claude --print with -p flag crashes with unhandled promise rejection: Error: No messages returned
- Process hangs indefinitely after the error instead of exiting with a non-zero code
- stderr output:
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 lEB (/$bunfs/root/claude:5989:78)
Steps to Reproduce
- Line 3663: Last successful API stream started at 00:58:24
- Line 3664: The model called TodoWrite at 00:58:27
- Lines 3668-3673: TodoWrite executed successfully, wrote to a JSON file
- Lines 3677-3804: ~130 ToolSearch:optimistic debug lines spammed in 4ms (something looping)
- Line 3805-3809: Another API request was made, stream started at 00:58:30
- Line 3810: The stream returned a Stop event at 00:58:43 — the model finished its response
- Line 3813: A hook ran and returned non-JSON output
- Line 3814: End of log — then the unhandled Error: No messages returned crash
So the crash happened right after the final API response completed and a Stop hook fired. The model completed
its turn, the hook ran, and then the CLI crashed with No messages returned when trying to process the next
turn. The TodoWrite was the last tool call before the crash.
This looks like a Claude CLI bug where the --print mode fails to handle the stop/completion event properly
after a hook returns plain text. The debug log file path is
~/.claude/debug/c473f69c-8473-48ab-91be-deb9582b888e.txt if you want to attach it to a GitHub issue.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.19
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Other
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗