feat(client, server): add keep-alive for streaming batch responses - #1657
Conversation
Send zero-length length-prefixed frames while streaming batch responses are idle (default 15s, configurable).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
More templates
@orpc/arktype
@orpc/bun
@orpc/client
@orpc/cloudflare
@orpc/contract
@orpc/experimental-effect
@orpc/evlog
@orpc/json-schema
@orpc/nest
@orpc/next
@orpc/openapi
@orpc/opentelemetry
@orpc/pino
@orpc/publisher
@orpc/ratelimit
@orpc/server
@orpc/shared
@orpc/tanstack-query
@orpc/valibot
@orpc/zod
commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Important
Two issues need attention before merging: the keepAlive.enabled option is typed as required (so { interval: ... } is rejected), and enabling keep-frames by default breaks backward compatibility with older clients that don't skip zero-length frames.
Reviewed changes — added server-side keep-alive frames for streaming batch responses and updated the client decoders to ignore zero-length frames.
- Add
keepAliveoption toBatchHandlerPlugin— configurableenabled/intervalfor streaming mode only. - Send zero-length length-prefixed frames from the server while the streaming batch response is idle, with timer lifecycle management.
- Skip zero-length frames in
decodeLengthPrefixedBlobanddecodeLengthPrefixedStreamso clients tolerate keep-alive frames. - Document keep-alive in
apps/content/docs/plugins/batch.mdand reorder the Filtering Requests section. - Add tests for both client and server keep-alive behavior.
Kimi K2 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Important
The latest commit only reordered documentation, so the two issues flagged in the prior review remain unaddressed (the related review threads were resolved without corresponding code changes).
Reviewed changes — commit 9a61c719 moved the Filtering Requests section in apps/content/docs/plugins/batch.md; packages/server/src/plugins/batch.ts was not changed.
- Reordered
apps/content/docs/plugins/batch.mdso Filtering Requests appears after Groups. - No code changes since the prior review.
Kimi K2 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Important
The streaming-only scope change is a good cleanup, but the two issues raised in prior reviews are still present in the current code.
Reviewed changes — commit 3832cc4a narrowed keep-alive to streaming mode by removing the blob test and zero-length-frame handling.
- Scoped keep-alive to streaming mode — removed the buffered/blob client test and
decodeLengthPrefixedBlobhandling. - Kept stream decoder handling unchanged —
decodeLengthPrefixedStreamstill skips zero-length frames and has a passing streaming test. - Did not change the server plugin API or defaults —
keepAlive.enabledis still typed as required and still defaults totrue.
Kimi K2 (free via Pullfrog for OSS) | 𝕏

Send zero-length length-prefixed frames while streaming batch responses are idle (default 15s, configurable).