Repository navigation
feat: End a stream with an error when neither an event nor a heartbeat arrives for 30 seconds. - #413
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
observeEventsandrunEventQlQuery. If the connection stalls without being closed (for example behind a proxy that keeps it open but passes nothing anymore), the client waited until Node's fetch gave up after five minutes with a genericTypeError: terminated, and an application observing events kept believing it was live until then. The same change is made in all seven client SDKs.observeEventsandrunEventQlQuerynow throw the newHeartbeatTimeoutError(an exported class,name'HeartbeatTimeoutError', "No event and no heartbeat arrived for 30 seconds.") when no line, heartbeat included, arrives for 30 seconds. The SDK cancels the body reader, which closes the socket.AbortSignalorbreakends the stream quietly, as before.readEventTypesskips heartbeat lines, but the server never sends any there, so it stays unchanged, as doreadEventsandreadSubjects.exportsmap does not expose, so the public API only grows by the error class.Tests (
src/heartbeatTimeout.test.ts, localnode:httpserver, 9 tests): stall → error and the connection closed (with and without a caller signal); heartbeats keep it alive; events and rows in time are delivered; a slow caller gets no timeout; caller abort ends quietly. Red first: both stall tests ran into their 5 s guard.npm run qagreen (tsc, biome with--error-on-warnings, 74 tests);npm run buildgreen.🤖 Generated with Claude Code
https://claude.ai/code/session_01TCdPte6nY6ToUVd2prb9GM