Skip to content

Process crashes when aborting a query before first response #121

@shellicar

Description

@shellicar

Observed behaviour

When a query is sent and then immediately aborted (Escape pressed before any response text appears), the entire process crashes with an unhandled error:

u$ [Error]: Operation aborted
    at Q0.write (file:///Users/stephen/Library/pnpm/global/5/.pnpm/@anthropic-ai+claude-agent-sdk@0.2.83_zod@4.3.6/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs:19:6997)
    at G0.handleControlRequest (file:///Users/stephen/Library/pnpm/global/5/.pnpm/@anthropic-ai+claude-agent-sdk@0.2.83_zod@4.3.6/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs:20:161)
    at process.processTicksAndRejections (node:internal/process/task_queues:104:5)

Expected behaviour

Aborting a query should cancel it gracefully and return to the prompt, regardless of timing. This works correctly when Escape is pressed after output has started.

Reproduction

  1. Start claude-cli
  2. Send any query
  3. Immediately press Escape (before any response text appears)
  4. Process crashes with the stack trace above

Environment

  • @anthropic-ai/claude-agent-sdk@0.2.83
  • Node.js v24.14.1

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions