[Bug] claude --continue hangs when stdout captured in non-TTY environment
Bug Description
Bug: claude --continue -p 'prompt' hangs when stdout is captured via $() in a non-TTY environment (e.g. AWS
SSM). Works fine when stdout is a terminal. Reproducible with repro-claude-continue-hang.sh:
#!/bin/bash
Minimal reproduction: claude --continue -p hangs in $() when run via SSM
#
Expected: both DIRECT and CAPTURED print PONG
Actual: DIRECT prints PONG, CAPTURED hangs (timeout after 15s)
#
Usage:
INSTANCE=i-XXXXX ./scripts/repro-claude-continue-hang.sh
REGION=us-east-2
: "${INSTANCE:?Set INSTANCE=i-XXXXX}"
SCRIPT=$(cat << 'INNER' | base64 -w 0
#!/bin/bash
mkdir -p /tmp/repro && cd /tmp/repro
echo hi | claude -p --dangerously-skip-permissions 2>/dev/null
echo "DIRECT: $(timeout 15 claude --continue -p --dangerously-skip-permissions 'Say PONG' 2>/dev/null)"
echo "CAPTURED: $(timeout 15 bash -c 'echo $(claude --continue -p --dangerously-skip-permissions "Say PONG" 2>/dev/null)')"
INNER
)
CMD_ID=$(aws ssm send-command --region $REGION \
--instance-ids $INSTANCE \
--document-name AWS-RunShellScript \
--timeout-seconds 60 \
--parameters "commands=[\"echo $SCRIPT | base64 -d | sudo -u agent -i bash\"]" \
--query 'Command.CommandId' --output text)
echo "Waiting 45s..."
sleep 45
aws ssm get-command-invocation --region $REGION \
--command-id $CMD_ID \
--instance-id $INSTANCE \
--query 'StandardOutputContent' --output text
Environment Info
- Platform: darwin
- Terminal: iTerm.app
- Version: 2.1.80
- Feedback ID: 493edb20-a78d-4b0e-93d5-12b72cec6a22
Errors
[{"error":"MaxFileReadTokenExceededError: File content (12960 tokens) exceeds maximum allowed tokens (10000). Use offset and limit parameters to read specific portions of the file, or search for specific content instead of reading the whole file.\n at z_9 (/$bunfs/root/src/entrypoints/cli.js:4268:23437)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-03-20T10:53:48.971Z"},{"error":"Error: Request was aborted.\n at ChT (/$bunfs/root/src/entrypoints/cli.js:2089:7936)\n at next (native:1:11)\n at eP9 (/$bunfs/root/src/entrypoints/cli.js:7208:7453)\n at next (native:1:11)\n at qJ9 (/$bunfs/root/src/entrypoints/cli.js:7213:9980)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-03-20T13:12:18.772Z"},{"error":"Error: Request was aborted.\n at makeRequest (/$bunfs/root/src/entrypoints/cli.js:254:3940)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-03-20T13:40:28.193Z"},{"error":"Error: Request was aborted.\n at ChT (/$bunfs/root/src/entrypoints/cli.js:2089:7936)\n at next (native:1:11)\n at eP9 (/$bunfs/root/src/entrypoints/cli.js:7208:7453)\n at next (native:1:11)\n at qJ9 (/$bunfs/root/src/entrypoints/cli.js:7213:9980)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-03-20T17:04:14.781Z"}]This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗