feat(hibernation): Hibernation APIs - #1763
Conversation
Port the v1 @orpc/server/hibernation module onto the v2 architecture as a dedicated @orpc/hibernation package. HibernationHandlerPlugin restores the HibernationAsyncIteratorClass response body that the RPC codec would otherwise wrap, and encodeHibernationRPCEvent produces peer event-stream messages byte-identical to the normal transmitter output. - v2 API naming with deprecated v1 aliases (HibernationPlugin, HibernationEventIterator) - encodeHibernationRPCEvent accepts a serializer instance and encodePeerMessage options; v1 event 'done' became 'close' to match the peer protocol - evlog/pino logging plugins order themselves before ~hibernation - docs page under Plugins with updated v2 examples; @orpc/hibernation added to the package list in all READMEs
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
More templates
@orpc/ai-sdk
@orpc/arktype
@orpc/bun
@orpc/client
@orpc/cloudflare
@orpc/contract
@orpc/experimental-effect
@orpc/evlog
@orpc/hibernation
@orpc/json-schema
@orpc/nest
@orpc/next
@orpc/openapi
@orpc/opentelemetry
@orpc/pinia-colada
@orpc/pino
@orpc/publisher
@orpc/ratelimit
@orpc/server
@orpc/shared
@orpc/swr
@orpc/tanstack-query
@orpc/trpc
@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.
✅ No new issues found.
Reviewed changes — port of v1 hibernation module to v2 as a new @orpc/hibernation package with plugin, encoder, deprecated aliases, docs, and README updates.
- New
@orpc/hibernationpackage —HibernationHandlerPlugin(routing + client interceptor),encodeHibernationRPCEvent, andHibernationAsyncIteratorClassre-export - Plugin ordering updates —
@orpc/pinoand@orpc/evlognow declarebefore: ['~hibernation']so logging interceptors run before the hibernation plugin - Docs and READMEs — VitePress page with Cloudflare Durable Object chat-room example; 20+ package READMEs now list
@orpc/hibernation
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — updated docs examples to v2-idiomatic os.$context<>() patterns and added a full Cloudflare Durable Object chat room playground with hibernation.
- Docs example modernization —
onMessageandsendMessageprocedures updated to use$contextand.input()chaining instead of bareos.handler() - Cloudflare playground —
HibernationChatRoomcomponent,chat-room.tsclient withRPCLink+ reconnect, andChatRoomDOserver withwithoutOpenTelemetry()helper for the DO'swebSocketMessage/webSocketClosehandlers - Wrangler config —
CHAT_ROOM_DONbinding and migration added to wrangler.jsonc
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Hibernation integrates an external platform API (Cloudflare's Hibernation WebSocket) rather than adding an oRPC-defined pipeline feature, so the page fits Integrations better than Plugins. Update sidebar and @see links accordingly.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — moved hibernation docs into the integrations section and inlined the OTEL disable helper in the playground DO.
- Docs reorganized to integrations — hibernation page moved from
docs/plugins/todocs/integrations/, sidebar link and page heading renamed to "Hibernation Integration", and JSDoc URLs inencode-event.tsandhandler-plugin.tsupdated to match - Playground OTEL helper inlined —
withoutOpenTelemetry()wrapper removed fromChatRoomDO; eachwebSocketMessage/webSocketClosehandler now creates and disables anORPCInstrumentationinstance directly
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

Ports the v1
@orpc/server/hibernationmodule to v2 as a dedicated@orpc/hibernationpackage, so Cloudflare WebSocket Hibernation (and similar) setups work again on v2. The plugin preservesHibernationAsyncIteratorClassoutputs through the RPC codec, andencodeHibernationRPCEventemits peerevent-streammessages that are byte-identical to what the normal transmitter sends — clients consume hibernated streams exactly like regular ones.API changes vs v1
HibernationHandlerPlugin,HibernationAsyncIteratorClass) with deprecated v1 aliases so old imports keep compiling and point at the new names.encodeHibernationRPCEventis now async, takes aserializerinstance (shareable withRPCHandler) and a dedicatedencodePeerMessageoptions field; the'done'event became'close'to match the peer protocol.before: ['~batch']; evlog/pino logging plugins now order themselves before~hibernationas well.Docs
@orpc/hibernationadded to the package list in all READMEs.Testing
event-streammessages for that id) and the encoder (byte parity withencodePeerMessage, event meta,close/errorevents, prefix, undefined payloads).pnpm type:check, lint, andunbuildpass; server/evlog/pino suites unaffected (450 tests green).