[BUG] [BashTool] Pre-flight check console.warn corrupts JSON output in Cowork tab, blocking tasks
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?
Description
When using the Cowork tab in the Claude desktop app, the BashTool pre-flight check warning message corrupts the JSON protocol between the app and the CLI, causing tasks to fail with:
> CLI output was not valid JSON. This may indicate an error during startup. Output: ⚠️ [BashTool] Pre-flight check is taking longer than expected. Run with ANTHROPIC_LOG=debug to check for failed or
slow API requests.
This completely blocks Cowork tab usage. The Chat tab and Code tab work fine.
## Root cause
In cli.js, the pre-flight check has a setTimeout at 10 seconds that calls console.warn(). When Claude Code runs inside the desktop app's Linux VM with gvisor networking, the Haiku API call for
bash command prefix detection takes >10s, triggering the warning. The warning text gets mixed into the JSON output, breaking the desktop app's JSON parser.
## Suggested fix
- Use
process.stderr.write()instead ofconsole.warn()and ensure the desktop app doesn't capture stderr as part of the JSON protocol - Or increase the timeout for VM/cowork contexts
- Or suppress the warning entirely when running in non-interactive/JSON mode
## Environment
- macOS (Darwin 25.2.0, ARM64)
- Claude desktop app (latest)
- Bundled Claude Code VM version: 2.1.34
- System Claude Code: 2.1.39
- coworkNetworkMode: gvisor
What Should Happen?
The Cowork tab should function without errors. The BashTool pre-flight check warning should not be output to stdout/JSON protocol, so it doesn't corrupt the communication between the desktop app and the CLI running in the VM.
Error Messages/Logs
CLI output was not valid JSON. This may indicate an error during startup. Output: ⚠️ [BashTool] Pre-flight check is taking longer than expected. Run with ANTHROPIC_LOG=debug to check for failed or slow API requests.
Steps to Reproduce
- Open Claude desktop app (latest version, macOS ARM64)
- Open the Cowork tab
- Start any task that requires Claude Code to run a bash command
- Wait ~10 seconds
- Task fails with: "CLI output was not valid JSON. This may indicate an error during startup. Output: ⚠️ [BashTool] Pre-flight check is taking longer than expected. Run with ANTHROPIC_LOG=debug to
check for failed or slow API requests."
Note: Chat tab and Code tab work fine. Only the Cowork tab is affected.
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.1.34
Claude Code Version
2.1.39
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗