feat(server): stable hibernation apis#854
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Caution Review failedThe pull request is closed. WalkthroughRenamed experimental-prefixed hibernation exports to canonical names across server, standard-server, and durable-event-iterator packages. Updated imports, types, re-exports, instanceof checks, tests, and docs to use HibernationPlugin, HibernationEventIterator, and encodeHibernationRPCEvent. No logic or control-flow changes. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Summary of Changes
Hello @unnoq, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
I'm stabilizing the hibernation APIs by removing the "experimental_" prefix from HibernationPlugin, HibernationEventIterator, and encodeHibernationRPCEvent. This change signifies that these APIs are now considered stable and ready for general use, impacting both the server-side implementation and related documentation.
Highlights
- API Stabilization: HibernationPlugin: I've removed the "experimental_" prefix from the
HibernationPluginclass, marking it as stable. - API Stabilization: HibernationEventIterator: I've similarly removed the "experimental_" prefix from the
HibernationEventIteratorclass, indicating its readiness for production use. - API Stabilization: encodeHibernationRPCEvent: The
encodeHibernationRPCEventfunction and its associated options interface have also shed their "experimental_" prefix, signifying their stable status. - Codebase-wide Updates: All relevant documentation, test files, and internal code references across various packages have been updated to reflect these new stable API names.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This pull request stabilizes the hibernation APIs by removing the experimental_ prefix from related classes, interfaces, and functions. The changes are applied consistently across the codebase, including documentation, source files, and tests. The refactoring is clean, thorough, and well-executed. I've reviewed the changes and found no issues.
More templates
@orpc/arktype
@orpc/client
@orpc/contract
@orpc/experimental-durable-event-iterator
@orpc/hey-api
@orpc/json-schema
@orpc/json-schema-typed
@orpc/nest
@orpc/openapi
@orpc/openapi-client
@orpc/otel
@orpc/react
@orpc/react-query
@orpc/server
@orpc/shared
@orpc/solid-query
@orpc/standard-server
@orpc/standard-server-aws-lambda
@orpc/standard-server-fetch
@orpc/standard-server-node
@orpc/standard-server-peer
@orpc/svelte-query
@orpc/tanstack-query
@orpc/trpc
@orpc/valibot
@orpc/vue-colada
@orpc/vue-query
@orpc/zod
commit: |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
packages/durable-event-iterator/src/durable-object/websocket-manager.ts (1)
8-9: Optional: widen options type to support event overridesIf you foresee sending 'error' or 'done' events, consider widening the manager options to EncodeHibernationRPCEventOptions for flexibility.
-import type { StandardRPCJsonSerializerOptions } from '@orpc/client/standard' +import type { StandardRPCJsonSerializerOptions } from '@orpc/client/standard' +import type { EncodeHibernationRPCEventOptions } from '@orpc/server/hibernation' @@ -export interface DurableEventIteratorObjectWebsocketManagerOptions extends StandardRPCJsonSerializerOptions { +export interface DurableEventIteratorObjectWebsocketManagerOptions extends EncodeHibernationRPCEventOptions { }apps/content/docs/plugins/hibernation.md (1)
13-13: Docs: adopt stable names + small polish suggestionsThe imports now use stable exports. Two small nits to improve snippets:
- Add ORPCError import where used in “Send events” snippet.
- Optional: unify “getWebSockets” vs “getWebsockets” naming across the example for consistency.
Suggested tweak for the “Send events” snippet:
- import { encodeHibernationRPCEvent } from '@orpc/server/hibernation' + import { encodeHibernationRPCEvent } from '@orpc/server/hibernation' + import { ORPCError } from '@orpc/client'And consider standardizing the helper name to one variant (e.g., getWebSockets) throughout the example.
Also applies to: 29-29, 42-42, 73-76
packages/server/src/hibernation/plugin.ts (1)
25-25: Hibernation context initializationInitialization is straightforward. Optional hardening: place the symbol after spreading user context so the plugin’s context cannot be overridden accidentally.
- context: { - [this.CONTEXT_SYMBOL]: hibernationContext, - ...options.context, - }, + context: { + ...options.context, + [this.CONTEXT_SYMBOL]: hibernationContext, + },This avoids false positives of the “corrupted” error if another interceptor mistakenly sets the same symbol reference.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (16)
apps/content/docs/plugins/hibernation.md(4 hunks)packages/durable-event-iterator/src/durable-object/handler.test.ts(1 hunks)packages/durable-event-iterator/src/durable-object/handler.ts(1 hunks)packages/durable-event-iterator/src/durable-object/object.ts(1 hunks)packages/durable-event-iterator/src/durable-object/websocket-manager.test.ts(1 hunks)packages/durable-event-iterator/src/durable-object/websocket-manager.ts(1 hunks)packages/server/src/hibernation/event-iterator.test.ts(1 hunks)packages/server/src/hibernation/event-iterator.ts(2 hunks)packages/server/src/hibernation/index.ts(1 hunks)packages/server/src/hibernation/plugin.test.ts(1 hunks)packages/server/src/hibernation/plugin.ts(3 hunks)packages/server/src/procedure-client.ts(1 hunks)packages/standard-server-peer/src/server.test.ts(1 hunks)packages/standard-server-peer/src/server.ts(2 hunks)packages/standard-server/src/hibernation.test.ts(1 hunks)packages/standard-server/src/hibernation.ts(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (4)
packages/standard-server-peer/src/server.ts (2)
packages/server/src/hibernation/index.ts (1)
HibernationEventIterator(3-3)packages/standard-server/src/hibernation.ts (1)
HibernationEventIterator(7-26)
packages/standard-server/src/hibernation.ts (2)
packages/server/src/hibernation/index.ts (2)
HibernationEventIteratorCallback(3-3)HibernationEventIterator(3-3)packages/shared/src/iterator.ts (1)
AsyncIteratorClass(25-98)
packages/server/src/hibernation/event-iterator.ts (1)
packages/client/src/adapters/standard/rpc-json-serializer.ts (1)
StandardRPCJsonSerializerOptions(25-27)
packages/server/src/hibernation/plugin.ts (4)
packages/server/src/hibernation/index.ts (1)
HibernationEventIterator(3-3)packages/standard-server/src/hibernation.ts (1)
HibernationEventIterator(7-26)packages/server/src/context.ts (1)
Context(1-1)packages/server/src/adapters/standard/plugin.ts (1)
StandardHandlerPlugin(5-8)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: publish-commit
- GitHub Check: lint
- GitHub Check: test
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (22)
packages/server/src/hibernation/event-iterator.ts (3)
8-19: Stable options interface looks goodEncodeHibernationRPCEventOptions cleanly extends StandardRPCJsonSerializerOptions and documents the event union with a sane default. No issues spotted.
26-48: encodeHibernationRPCEvent: implementation/typing LGTM
- Defaulted options param and event destructuring are correct.
- Error branch normalization via toORPCError().toJSON() is appropriate.
- meta trimming to undefined avoids noisy payloads.
26-48: Stable hibernation API re-exports are in place; noexperimental_prefixes remain
Allexperimental_…symbols have been removed, and the core hibernation exports are correctly re-exported frompackages/server/src/hibernation/index.ts:
encodeHibernationRPCEvent(viaexport * from './event-iterator')HibernationEventIterator&HibernationEventIteratorCallback(viaexport { … } from '@orpc/standard-server')HibernationPlugin(viaexport * from './plugin')No further action required.
packages/standard-server/src/hibernation.ts (1)
3-15: Canonical iterator types: rename and typing are correct
- Callback interface and class names are stabilized.
- Optional hibernationCallback property is appropriate for non-transfer to clients.
- Constructor/cleanup behavior aligns with tests and AsyncIteratorClass contract.
packages/standard-server/src/hibernation.test.ts (1)
1-1: Test import updated to canonical symbolImport now targets HibernationEventIterator directly; tests remain valid and exercise the expected behavior.
packages/durable-event-iterator/src/durable-object/websocket-manager.ts (1)
5-5: Switched to stable encoder import: goodUsing encodeHibernationRPCEvent from @orpc/server/hibernation aligns with the stabilized API surface.
packages/durable-event-iterator/src/durable-object/handler.ts (1)
6-6: Stable iterator import adoptedImporting HibernationEventIterator from @orpc/server/hibernation is consistent with the new public API. No behavior changes.
packages/durable-event-iterator/src/durable-object/object.ts (1)
7-7: Stable plugin import adoptedHibernationPlugin imported from @orpc/server/hibernation with no logic changes. Looks good.
packages/durable-event-iterator/src/durable-object/handler.test.ts (1)
2-2: Test import switched to canonical iteratorDirectly importing HibernationEventIterator keeps tests aligned with the stabilized API.
packages/server/src/hibernation/plugin.test.ts (2)
1-1: Use of canonical HibernationEventIterator in testImport updated to the stable symbol from @orpc/standard-server. Good alignment with the new API.
4-4: HibernationPlugin import stabilizationImporting HibernationPlugin directly from ./plugin is consistent with the rest of the PR. No issues.
packages/durable-event-iterator/src/durable-object/websocket-manager.test.ts (1)
8-8: Spy target rename looks correctSwitched spy from experimental to stable export; matches the updated server hibernation index re-exports. No behavior change.
packages/server/src/procedure-client.ts (1)
11-11: Import updated to stable HibernationEventIteratorAligns with the new public API. The instanceof guard below will continue to short-circuit wrapping. No further action needed.
packages/standard-server-peer/src/server.test.ts (1)
2-2: Test import aligned with stable exportDirectly importing HibernationEventIterator is consistent with the new API surface. Assertions relying on instanceof remain valid.
packages/server/src/hibernation/event-iterator.test.ts (1)
6-6: Use of encodeHibernationRPCEvent is consistent with the API renameThe tests still cover message, meta, done, and error cases. Looks good.
packages/server/src/hibernation/index.ts (1)
3-3: Re-exporting stable iterator and callback from standard-serverThis keeps server consumers on canonical symbols and avoids duplicating definitions. Good change.
packages/standard-server-peer/src/server.ts (1)
6-6: Stable HibernationEventIterator import and guard
- Import source updated to @orpc/standard-server and instanceof check targets the stable class. Matches tests and re-exports.
- Minor note: ensure dependency graph dedupes @orpc/standard-server to avoid instanceof failing across multiple copies, especially in workspace builds.
If you want, we can add a quick sanity check in CI to assert a single resolved copy of @orpc/standard-server (e.g., via pnpm list/npm ls) to prevent instanceof pitfalls.
Also applies to: 162-164
packages/server/src/hibernation/plugin.ts (5)
4-4: Import stable HibernationEventIteratorImport aligns with the new canonical class location. OK.
6-8: Public context type renameExported HibernationPluginContext looks good and keeps type surface stable post-rename.
15-15: Plugin class rename to HibernationPluginMatches docs and re-exports. No functional differences introduced.
49-49: Context retrieval via symbolLooks correct; throws early if the context was corrupted. This keeps failures explicit.
57-59: instanceof check targeting stable iterator classThe capture of the iterator into plugin context continues to work with the new class. Be mindful of potential multiple copies of the package in monorepo builds, which can break instanceof checks.
Optionally guard with a brand check fallback to future-proof against duplicate module instances:
- Add a static symbol or property on the class and test for it when instanceof fails.
Summary by CodeRabbit
Refactor
Documentation
Tests
Chores