[Bug] Stream destroyed error when writing to output after stream closure

Resolved 💬 3 comments Opened Jan 8, 2026 by nrupatunga Closed Jan 12, 2026

Bug Description
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 [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed
at _write (node:internal/streams/writable:483:11)
at Writable.write (node:internal/streams/writable:502:10)
at file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:2312:14632
at new Promise (<anonymous>)
at lv2.write (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:2312:14526)
at X$0.doWrite (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:2284:1708)
at file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:2284:1604

Environment Info

  • Platform: linux
  • Terminal: tmux
  • Version: 2.1.1
  • Feedback ID: 6b2306b4-7327-47f9-8430-3c306464234d

Errors

[{"error":"Error: LSP server plugin:pyright-lsp:pyright failed to start: spawn pyright-langserver ENOENT\n    at Object.start (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:2312:22351)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async Object.X [as start] (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:2312:24787)","timestamp":"2026-01-08T17:44:39.779Z"},{"error":"Error: spawn pyright-langserver ENOENT\n    at ChildProcess._handle.onexit (node:internal/child_process:286:19)\n    at onErrorNT (node:internal/child_process:484:16)\n    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)","timestamp":"2026-01-08T17:44:39.781Z"},{"error":"Error: Failed to start LSP server plugin:pyright-lsp:pyright: spawn pyright-langserver ENOENT\n    at file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:2312:32565\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)","timestamp":"2026-01-08T17:44:39.781Z"},{"error":"Error: LSP server plugin:lua-lsp:lua crashed with exit code 1\n    at ChildProcess.<anonymous> (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:2312:21508)\n    at ChildProcess.emit (node:events:519:28)\n    at ChildProcess.emit (node:domain:488:12)\n    at ChildProcess._handle.onexit (node:internal/child_process:294:12)","timestamp":"2026-01-08T17:44:39.787Z"},{"error":"Error: LSP server plugin:lua-lsp:lua connection error: Cannot call write after a stream was destroyed\n    at file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:2312:21798\n    at ry2.invoke (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:2282:14959)\n    at zW1.fire (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:2282:15748)\n    at s (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:2286:6167)\n    at ry2.invoke (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:2282:14959)\n    at zW1.fire (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:2282:15748)\n    at X$0.fireError (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:2284:413)\n    at X$0.handleError (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:2284:1854)\n    at X$0.doWrite (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:2284:1778)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)","timestamp":"2026-01-08T17:44:39.788Z"},{"error":"Error: LSP server plugin:lua-lsp:lua initialize failed: Cannot call write after a stream was destroyed\n    at Object.initialize (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:2312:22649)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async Object.X [as start] (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:2312:25654)","timestamp":"2026-01-08T17:44:39.788Z"},{"error":"Error: Cannot call write after a stream was destroyed\n    at file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:2312:4003\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)","timestamp":"2026-01-08T17:44:39.788Z"},{"error":"Error: Failed to start LSP server plugin:lua-lsp:lua: Cannot call write after a stream was destroyed\n    at file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:2312:32565\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)","timestamp":"2026-01-08T17:44:39.788Z"}]

View original on GitHub ↗

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