Skip to content

feat: send periodic SSE heartbeats to reap half-open connections - #50

Merged
bpolaszek merged 2 commits into
bpolaszek:mainfrom
geonativefr:feat/heartbeat-reaper
Jul 3, 2026
Merged

bpolaszek merged 2 commits into
bpolaszek:mainfrom
geonativefr:feat/heartbeat-reaper

Conversation

@LounisBou

Copy link
Copy Markdown
Contributor

Idle SSE subscribers whose client dies silently (mobile drop, laptop sleep, NAT/proxy timeout) never emit a stream close, so they leak in the transport's topic index (~kernel keepalive, ~2h) and keep getting re-matched on every publish, wasting CPU.

This adds a periodic SSE heartbeat (:\n SSE comment) per subscription. It (a) keeps live connections open through reverse-proxy idle timeouts and (b) forces a TCP write on half-open peers so the kernel detects the dead connection and emits close, triggering the existing unsubscribe path.

  • New heartbeat_interval hub option (default 40s), configurable via HEARTBEAT_INTERVAL env; 0 disables.

@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (babfcd2) to head (33613c5).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##                main       #50   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
  Complexity       165       165           
===========================================
  Files             27        27           
  Lines            437       443    +6     
===========================================
+ Hits             437       443    +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bpolaszek

Copy link
Copy Markdown
Owner

👌

@bpolaszek
bpolaszek merged commit 1c168b1 into bpolaszek:main Jul 3, 2026
18 checks passed
@LounisBou LounisBou mentioned this pull request Jul 7, 2026
@misaert
misaert deleted the feat/heartbeat-reaper branch July 7, 2026 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants