Repository navigation
fix: Keep a stream open for as long as it runs, rather than end it after five minutes. - #269
Merged
Merged
Conversation
…ter five minutes. The aiohttp session used aiohttp's default timeout, whose total of five minutes also covers reading the response body. Every stream therefore ended with a TimeoutError after five minutes, even while the server kept sending heartbeats. Requests that read a stream (read events, run an EventQL query, observe events, read subjects, read event types) now have no total limit, only the 30 seconds for connecting. All other requests keep the limit of the session. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TCdPte6nY6ToUVd2prb9GM
…of the stream timeout need no server of their own. 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.
HttpClientcreated itsaiohttp.ClientSessionwithout a timeout, so aiohttp used its defaultClientTimeout(total=300, sock_connect=30), andtotalalso covers reading the response body. Everyobserve_eventsstream therefore ended after exactly five minutes with a bareTimeoutError, even while the server sent a heartbeat every second, and so did any other stream that legitimately ran longer (a longrun_eventql_query,read_eventsover a big store).read_events,run_eventql_query,observe_events,read_subjects,read_event_types) passis_stream=TruetoHttpClient.post, which gives that requestClientTimeout(total=None, sock_connect=30): no limit on how long it runs, while connecting still fails after 30 seconds. How long a stream may run is up to the caller (for example withasyncio.timeout); a stalled observe stream or query ends after 30 seconds without a line through the heartbeat timeout (feat: End a stream with an error when neither an event nor a heartbeat arrives for 30 seconds. #268).ping,write_events,verify_api_token,register_event_schema,read_event_type) keeps the session's limit, unchanged. It is per request because aiohttp reads a per-requesttimeout=Noneas no limit at all, connecting included. The publicClientAPI is unchanged;HttpClient.postonly gains an optional argument.Tests (with aiohttp's default patched to a 1 s total): observing against the real EventSourcingDB container stays open for the test's full 3 s deadline; a query against the local server sending heartbeats does the same; a write to a server that never sends its body still ends through the session limit, before the deadline. Red first: both stream tests ended after 1.01 s / 1.00 s through the session limit. A deliberately over-broad fix (no total for the whole session) fails the write guard.
make qagreen (lock check, ruff, pyright, bandit, 92 tests).🤖 Generated with Claude Code
https://claude.ai/code/session_01TCdPte6nY6ToUVd2prb9GM