claude-code - 💡(How to fix) Fix [FEATURE] Feature Request: SSE keep-alive / heartbeat during tool execution [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#45224Fetched 2026-04-09 08:10:23
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×4commented ×1

Error Message

improvements for error handling"

Fix Action

Fix / Workaround

Current workarounds

RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing requests and this feature hasn't been requested yet
  • This is a single feature request (not multiple features)

Problem Statement

Problem

When Claude Code executes long-running tools (e.g. reading large files), the SSE stream goes silent until the tool completes. During this idle period, corporate HTTP proxies with connection idle timeouts (typically 60–120s) drop the connection, causing persistent ECONNRESET errors.

Once a session hits this state, retries keep failing on the same broken connection. A fresh session works again — but only until the next long tool execution.

This affects users behind corporate networks who cannot modify proxy/firewall timeout settings.

Expected behavior

The API should send periodic SSE keep-alive comments (e.g. : ping or empty SSE comments) during tool execution to keep the connection alive through proxies.

This is a well-established pattern — for example, OpenAI sends empty SSE comments during long-running streaming responses for exactly this reason.

Proposed Solution

Suggestion

Implement periodic SSE keep-alive messages (e.g. every 15–30s) on the API stream during tool execution phases, so that proxies and firewalls see ongoing traffic and don't terminate the connection.

Alternative Solutions

Current workarounds

None of these fully solve the problem:

  • /clear and /compact help avoid context buildup but don't prevent long individual tool executions from stalling.
  • CLAUDE_ENABLE_STREAM_WATCHDOG=1 only aborts stalled streams faster — it doesn't prevent the drop.
  • Splitting reads into smaller chunks is possible but defeats the purpose of agentic tool use.
  • Using a mobile hotspot to bypass the corporate proxy works but is impractical as a permanent solution.

Priority

Critical - Blocking my work

Feature Category

CLI commands and flags

Use Case Example

Use Case Example

A developer working on a large Java/Angular monorepo uses Claude Code to analyze and refactor code. A typical task:

"Read src/main/java/com/example/service/PaymentService.java and suggest improvements for error handling"

The file is ~800 lines. Claude Code starts a tool execution to read the file. During this phase, the SSE stream goes silent for 60-90 seconds. The corporate proxy interprets this as an idle connection and drops it → ECONNRESET.

The developer now has to:

  1. Start a fresh session (/clear)
  2. Manually split the file (head -n 200 ... | claude)
  3. Repeat for each chunk
  4. Mentally stitch the results together

This turns a single 30-second agentic task into a 10-minute manual workflow, eliminating the core value proposition of Claude Code as an autonomous coding agent.

With SSE keep-alive, the proxy would see ongoing traffic during tool execution and the entire flow would complete without interruption.

Additional Context

Environment

  • Claude Code CLI (latest)
  • Behind corporate HTTP proxy with ~60–120s idle timeout
  • Windows + WSL

extent analysis

TL;DR

Implementing periodic SSE keep-alive messages during tool execution phases can prevent corporate HTTP proxies from dropping the connection due to idle timeouts.

Guidance

  • Identify the optimal interval for sending SSE keep-alive comments (e.g., every 15-30 seconds) to ensure proxies and firewalls see ongoing traffic.
  • Modify the API to send periodic SSE keep-alive messages during tool execution phases, such as sending empty SSE comments or : ping comments.
  • Test the implementation with different proxy idle timeout settings to verify its effectiveness.
  • Consider adding a configurable option to adjust the keep-alive interval to accommodate varying proxy settings.

Example

// Example of sending SSE keep-alive comments every 15 seconds
setInterval(() => {
  // Send an empty SSE comment or a : ping comment
  res.write(': ping\n\n');
}, 15000);

Notes

The proposed solution assumes that the API has control over the SSE stream and can send keep-alive messages during tool execution phases. The optimal interval for sending keep-alive comments may vary depending on the specific proxy settings and requirements.

Recommendation

Apply the workaround by implementing periodic SSE keep-alive messages during tool execution phases, as this is a well-established pattern for preventing connection drops due to idle timeouts.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

The API should send periodic SSE keep-alive comments (e.g. : ping or empty SSE comments) during tool execution to keep the connection alive through proxies.

This is a well-established pattern — for example, OpenAI sends empty SSE comments during long-running streaming responses for exactly this reason.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING