fix(gateway): force reconnect stale Signal SSE streams#71098
Open
fangliquanflq wants to merge 1 commit into
Open
fix(gateway): force reconnect stale Signal SSE streams#71098fangliquanflq wants to merge 1 commit into
fangliquanflq wants to merge 1 commit into
Conversation
When the SSE receive path stalls for >120s without keepalives or events, always call _force_reconnect() instead of resetting the idle clock on a healthy daemon HTTP /check response. The /check probe remains diagnostics only.
13 tasks
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes a Signal gateway bug where inbound messages could stop permanently while the adapter still looked connected. When the SSE receive stream stalled for more than 120 seconds, the health monitor refreshed the idle clock if the daemon HTTP check returned 200 instead of forcing a reconnect.
Bug Cause
In
gateway/platforms/signal.py,_health_monitor()treated a 200 fromGET /api/v1/checkas proof the receive path was healthy and reset_last_sse_activity. After #3316, signal-cli sends SSE:keepalive comments about every 15 seconds, so crossingHEALTH_CHECK_STALE_THRESHOLD(120s) means the stream itself is hung, not merely quiet. Resetting the idle clock left the dead SSE connection open and_sse_listener()never entered its reconnect/backoff loop.Reproduction Steps
/api/v1/events(for example proxy drops further bytes, half-open TCP, or a stuck daemon event thread) whileGET /api/v1/checkstill returns 200.Expected: the health monitor forces an SSE reconnect and inbound messages resume.
Before fix: logs show repeated "daemon healthy, SSE idle" debug lines,
_last_sse_activitykeeps getting refreshed, and inbound messages never resume until process restart.Fix
When SSE activity is stale, call
_force_reconnect()immediately. The daemon/checkprobe runs afterward for diagnostics only and no longer refreshes_last_sse_activity. AddedTestSignalSseHealthMonitorto lock reconnect-on-stale behavior, call order (reconnect before probe), and the no-clock-refresh invariant.Related Issue
No issue - discovered via bug-hunter analysis of Signal SSE health monitoring.
Type of Change
Changes Made
gateway/platforms/signal.py- force reconnect on stale SSE before the diagnostic daemon health probetests/gateway/test_signal.py- addTestSignalSseHealthMonitorcoverage for stale/fresh/unhealthy/error pathsHow to Test
_force_reconnect(), and inbound messages resume without restarting the process.Checklist
Code
scripts/run_tests.shon relevant tests and they passDocumentation & Housekeeping
cli-config.yaml.exampleif I added/changed config keys - or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows - or N/A