[BUG] Process exits with code 1 after launching background Bash task

Resolved 💬 4 comments Opened Jan 6, 2026 by coygeek Closed Feb 19, 2026

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 Code crashes with exit code 1 immediately after launching a background Bash task using run_in_background: true. The crash occurs during the streaming response following the background task launch, before the user can respond.

The session transcript file is written as 0 bytes, indicating the crash happens before the session can be persisted. The VSCode extension shows "Error: Claude Code process exited with code 1".

What Should Happen?

Claude Code should:

  1. Successfully launch the background task
  2. Complete the streaming response asking the user how to proceed
  3. Wait for user input or continue working
  4. Not crash

Error Messages/Logs

From the VSCode Output panel (Claude Code channel):


2026-01-05 16:05:27.256 [info] From claude: 2026-01-06T00:05:27.256Z [DEBUG] Stream started - received first chunk
2026-01-05 16:05:29.761 [info] From claude: 2026-01-06T00:05:29.760Z [DEBUG] Stream started - received first chunk
2026-01-05 16:05:35.383 [info] From claude: 2026-01-06T00:05:35.383Z [DEBUG] Getting matching hook commands for Stop with query: undefined
2026-01-05 16:05:36.247 [info] From claude: 2026-01-06T00:05:36.247Z [DEBUG] LSP server manager shut down successfully
2026-01-05 16:05:36.630 [info] Closing Claude on channel: 2b8tqr40ivl
2026-01-05 16:05:36.631 [error] Error from Claude (on channel 2b8tqr40ivl): Error: Claude Code process exited with code 1


Key observation: The `Stop` event has `query: undefined`, which is unusual and suggests an abnormal termination rather than user-initiated stop.

Steps to Reproduce

  1. Open a project in VSCode with Claude Code extension
  2. Ask Claude to run a long-running command in the background:

``
Run
python3 -m some_module auto -v in the background
``

  1. Claude launches the Bash command with run_in_background: true
  2. Claude begins streaming a response like "Command running in background with ID: xxx. Want me to wait for it to complete?"
  3. Crash occurs - "Error: Claude Code process exited with code 1" appears

The crash appears to happen during the streaming response after the background task is launched, possibly due to a race condition.

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.0.76

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

Session file evidence

The session transcript file (*.jsonl) is 0 bytes after the crash, which indicates the session was not properly persisted before termination.

Log analysis

  1. All hooks completed successfully (green status messages in logs)
  2. Two API streams started at 16:05:27 and 16:05:29
  3. At 16:05:35, a Stop event fired with query: undefined (abnormal)
  4. SessionEnd hooks ran normally
  5. Process exited with code 1 at 16:05:36

Hypothesis

The crash appears related to a race condition between:

  • The background Bash task being spawned
  • The main conversation stream completing
  • The VSCode extension communication layer

The query: undefined in the Stop event suggests something triggered an unexpected shutdown path.

View original on GitHub ↗

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