Skip to content

fix (SSE): Prevent heartbeat from aborting in-progress connections#8783

Merged
ericpgreen2 merged 10 commits intomainfrom
fix-sse-disconnect
Feb 5, 2026
Merged

fix (SSE): Prevent heartbeat from aborting in-progress connections#8783
ericpgreen2 merged 10 commits intomainfrom
fix-sse-disconnect

Conversation

@ericpgreen2
Copy link
Contributor

@ericpgreen2 ericpgreen2 commented Feb 5, 2026

The heartbeat function is called on every user interaction (click, keydown, focus) to manage our SSE connection lifecycle. Previously, it would trigger reconnect() regardless of connection state, which caused problems during the CONNECTING phase—the in-progress connection would be aborted, burning through retry attempts until the max was exceeded, resulting in the "Error connecting to runtime" error page.

This is a latency-dependent race condition: locally, connections establish fast enough that the CONNECTING window is rarely hit. Behind proxies (Cloudflare, Codespaces), added latency widens this window, causing user interactions during page load to abort connections consistently.

This fix makes heartbeat() only trigger reconnect when the connection is PAUSED (intentionally disconnected to save resources), not when CONNECTING (already in progress) or CLOSED (fatal error).

I've tested this PR in GitHub Codespaces. See PR #8784 for the devcontainer setup.

Closes APP-719

Checklist:

  • Covered by tests
  • Ran it and it works as intended
  • Reviewed the diff before requesting a review
  • Checked for unhandled edge cases
  • Linked the issues it closes
  • Checked if the docs need to be updated. If so, create a separate Linear DOCS issue
  • Intend to cherry-pick into the release branch
  • I'm proud of this work!

@ericpgreen2 ericpgreen2 self-assigned this Feb 5, 2026
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@ericpgreen2 ericpgreen2 marked this pull request as ready for review February 5, 2026 10:23
@ericpgreen2 ericpgreen2 merged commit 13daf1c into main Feb 5, 2026
11 checks passed
@ericpgreen2 ericpgreen2 deleted the fix-sse-disconnect branch February 5, 2026 17:36
ericpgreen2 added a commit that referenced this pull request Feb 5, 2026
…8783)

* fix (SSE): Send server keep-alives

* Push a devcontainer for testing

* Bump devcontainer's Node heap size

* Fix devcontainer's Go version

* Add debugging logs

* Modify devcontainer so I can upload my own binary

* Fix heartbeat triggering reconnect during CONNECTING state

* Revert "fix (SSE): Send server keep-alives"

This reverts commit a719a8c.

* Remove SSE debugging logs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Remove devcontainer (moved to separate PR)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
ericpgreen2 added a commit that referenced this pull request Feb 5, 2026
…8783)

* fix (SSE): Send server keep-alives

* Push a devcontainer for testing

* Bump devcontainer's Node heap size

* Fix devcontainer's Go version

* Add debugging logs

* Modify devcontainer so I can upload my own binary

* Fix heartbeat triggering reconnect during CONNECTING state

* Revert "fix (SSE): Send server keep-alives"

This reverts commit a719a8c.

* Remove SSE debugging logs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Remove devcontainer (moved to separate PR)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants