Repository navigation
feat: End a stream with an error when neither an event nor a heartbeat arrives for 30 seconds. - #268
Merged
Merged
Conversation
…t arrives for 30 seconds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TCdPte6nY6ToUVd2prb9GM
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.
The server sends a heartbeat every second on the streams of
observe_eventsandrun_eventql_query. If the connection stalls without being closed (for example behind a proxy that keeps it open but passes nothing anymore), the client waited until some other timeout, and an application observing events kept believing it was live. The same change is made in all seven client SDKs.observe_eventsandrun_eventql_querynow raise the newHeartbeatTimeoutError(a subclass ofServerError, exported fromeventsourcingdbandeventsourcingdb.errors) when no line, heartbeat included, arrives for 30 seconds. The error propagates throughasync with response:, which closes the response and the connection.asyncio.timeoutperreadline()); the timeout never spans ayield, so the time the caller spends on an item does not count.HeartbeatTimeoutError. Any otherTimeoutError, and a caller's own cancellation or timeout, pass on unchanged.read_events,read_subjectsandread_event_typeshave no heartbeats and stay unchanged.Tests (
tests/test_heartbeat_timeout.py, local aiohttp server, both calls): stall →HeartbeatTimeoutErrorand the client disconnects; heartbeats keep it alive; items in time are delivered;task.cancel()and the caller's ownasyncio.timeoutare not reported as the new error; a foreignTimeoutErrorpasses unchanged. Red first: the stall tests ran into their 5 s guard.make qagreen (uv lock check, ruff, pyright, bandit, 89 tests with Docker); the new tests also pass under Python 3.14.🤖 Generated with Claude Code
https://claude.ai/code/session_01TCdPte6nY6ToUVd2prb9GM