[BUG] claude plugin list --json --available truncates stdout at 65536 bytes when piped (process.exit before pipe drains)

Open 💬 4 comments Opened May 30, 2026 by asharaf44

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 plugin list --json --available truncates its JSON output to exactly 65536 bytes (64 KB) when stdout is a pipe, producing invalid, unterminated JSON. This is the classic Node.js bug of calling process.exit() before async writes to a pipe have drained — only what fits in the OS pipe buffer (64 KB on macOS) gets flushed before the process exits.

Anything that captures the CLI's stdout through a pipe hits this. In particular, the VS Code extension shells out via execFile (which captures stdout through a pipe) when opening the plugin browser, so the response fails to JSON.parse and the plugin marketplace UI is unusable for any user whose available-plugin metadata exceeds ~64 KB. (Here: 204 available plugins ≈ 111 KB.)

What Should Happen?

The command should emit complete, valid JSON regardless of whether stdout is a pipe, a TTY, or a file. The full payload should be flushed before the process exits.

Error Messages/Logs

# Parsing the piped output:
Unterminated string starting at: line 1391 column 19 (char 65444)

# As surfaced by the VS Code extension (anthropic.claude-code 2.1.157):
[error] Error processing client request: SyntaxError: Unterminated string in JSON at position 65478 (line 1391 column 53)
[info]  Received message from webview: {"type":"interrupt_claude","channelId":"r0g94scnvyk"}
[warning] Channel not found: r0g94scnvyk

Steps to Reproduce

Preconditions: configure enough plugin marketplaces that claude plugin list --json --available produces more than ~64 KB of JSON (in my case 204 available plugins, ~111 KB).

  1. Pipe the command and count the bytes — it's capped at exactly the 64 KB pipe buffer:

``
$ claude plugin list --json --available | wc -c
65536
``

  1. Confirm the piped output is invalid (truncated mid-string):

``
$ claude plugin list --json --available | python3 -m json.tool >/dev/null
Unterminated string starting at: line 1391 column 19 (char 65444)
``

  1. Redirect the SAME command to a regular file instead — now it's complete and valid:

``
$ claude plugin list --json --available > out.json; wc -c < out.json
111710
$ python3 -m json.tool < out.json >/dev/null # no error; 204 plugins
``

Pipe → truncated to 65536 bytes, invalid JSON. File → full 111710 bytes, valid JSON. The truncation offset is identical on every run, ruling out a timing/race condition and pointing at a fixed pipe-buffer flush boundary.

Likely fix: flush stdout fully before exiting — set process.exitCode and return instead of calling process.exit(), or process.stdout.write(json, () => process.exit(0)), or await a 'drain' event on backpressure.

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.157

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

VS Code integrated terminal and VS Code extension

Additional Information

_No response_

View original on GitHub ↗

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