[BUG] `AbortError` is defined in TypeScript definitions but not exported at runtime in SDK

Resolved 💬 3 comments Opened Sep 4, 2025 by sugyan Closed Jan 7, 2026

Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.103
  • Operating System: macOS 15.6.1
  • Terminal: WezTerm

Bug Description

AbortError is exported in TypeScript definitions (sdk.d.ts) but not available at runtime in SDK version 1.0.103, causing import errors when trying to use it in error handling code.

Steps to Reproduce

  1. Create a TypeScript file example.ts:
import { query, AbortError } from "@anthropic-ai/claude-code";

(async () => {
  try {
    for await (const message of query({
      prompt: "hi",
    })) {
      console.log(message);
    }
  } catch (e) {
    if (e instanceof AbortError) {
      console.error(`AbortError: ${e.message}`);
    }
  }
})();
  1. Bundle with esbuild:
npx esbuild example.ts --bundle --platform=node --target=node20 --format=esm --external:@anthropic-ai/claude-code --outfile=example.js
  1. Run the bundled file: node example.js

Expected Behavior

Either:

  • AbortError should be exported from the module to match the TypeScript definitions, or
  • AbortError should be removed from the TypeScript definitions if it's not intended to be public

Actual Behavior

Runtime error occurs:

SyntaxError: The requested module '@anthropic-ai/claude-code' does not provide an export named 'AbortError'

Available exports are only: ['createSdkMcpServer', 'query', 'tool']

Additional Context

  • IDE/editor shows AbortError as available import due to TypeScript definitions
  • This breaks error handling patterns that developers might naturally write
  • The issue occurs in both bundled (with --external) and non-bundled scenarios

View original on GitHub ↗

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