Skip to content

feat(server): stable hibernation apis#854

Merged
dinwwwh merged 2 commits into
mainfrom
feat/server/stable-hibernation-apis
Aug 11, 2025
Merged

feat(server): stable hibernation apis#854
dinwwwh merged 2 commits into
mainfrom
feat/server/stable-hibernation-apis

Conversation

@dinwwwh
Copy link
Copy Markdown
Member

@dinwwwh dinwwwh commented Aug 11, 2025

Summary by CodeRabbit

  • Refactor

    • Stabilized Hibernation public API by removing experimental_ prefixes; use HibernationPlugin, HibernationEventIterator, and encodeHibernationRPCEvent.
    • Updated type names accordingly; no behavioral changes.
  • Documentation

    • Updated guides and examples to reflect new Hibernation API names and imports.
  • Tests

    • Adjusted imports and spies to use the stable Hibernation API names.
  • Chores

    • Aligned runtime checks and internal references with the new stable Hibernation API.

@vercel
Copy link
Copy Markdown

vercel Bot commented Aug 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
orpc ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 11, 2025 9:20am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Aug 11, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Renamed 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

Cohort / File(s) Summary
Core hibernation API
packages/standard-server/src/hibernation.ts, packages/server/src/hibernation/event-iterator.ts, packages/server/src/hibernation/plugin.ts, packages/server/src/hibernation/index.ts
Removed experimental_ prefixes: renamed interfaces/classes/functions and their exported types (HibernationEventIterator, HibernationEventIteratorCallback, HibernationPlugin, HibernationPluginContext, encodeHibernationRPCEvent, EncodeHibernationRPCEventOptions). Updated signatures/types and re-exports to canonical names.
Runtime consumers
packages/standard-server-peer/src/server.ts, packages/server/src/procedure-client.ts, packages/durable-event-iterator/src/durable-object/object.ts, packages/durable-event-iterator/src/durable-object/handler.ts, packages/durable-event-iterator/src/durable-object/websocket-manager.ts
Switched imports and runtime instanceof checks from experimental_* symbols to the canonical hibernation exports; usage and logic unchanged.
Tests
packages/standard-server/src/hibernation.test.ts, packages/standard-server-peer/src/server.test.ts, packages/server/src/hibernation/event-iterator.test.ts, packages/server/src/hibernation/plugin.test.ts, packages/durable-event-iterator/src/durable-object/handler.test.ts, packages/durable-event-iterator/src/durable-object/websocket-manager.test.ts
Updated test imports, spies, and assertions to reference canonical symbols (HibernationEventIterator, encodeHibernationRPCEvent, HibernationPlugin); no assertion or behavior changes.
Docs
apps/content/docs/plugins/hibernation.md
Updated examples and import statements to use HibernationPlugin, HibernationEventIterator, and encodeHibernationRPCEvent instead of experimental_* aliases.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • unnoq/orpc#854 — Directly renames the same experimental_* hibernation exports to canonical names across the codebase (high overlap).
  • unnoq/orpc#668 — Applies matching renames of hibernation exports used by durable-event-iterator and related modules.
  • unnoq/orpc#686 — Modifies hibernation plugin internals and context wiring that overlap with plugin.ts changes here.

Poem

I nibble through the prefix vines,
Toss out "experimental" lines.
Now names are neat and horizons wide,
Hibernation hops with steady stride.
A tiny rabbit, code and carrot pried. 🥕


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7b57284 and da3e723.

📒 Files selected for processing (1)
  • packages/server/src/hibernation/plugin.ts (3 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/server/stable-hibernation-apis

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 HibernationPlugin class, marking it as stable.
  • API Stabilization: HibernationEventIterator: I've similarly removed the "experimental_" prefix from the HibernationEventIterator class, indicating its readiness for production use.
  • API Stabilization: encodeHibernationRPCEvent: The encodeHibernationRPCEvent function 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

  1. 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.

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Aug 11, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Aug 11, 2025

More templates

@orpc/arktype

npm i https://pkg.pr.new/@orpc/arktype@854

@orpc/client

npm i https://pkg.pr.new/@orpc/client@854

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@854

@orpc/experimental-durable-event-iterator

npm i https://pkg.pr.new/@orpc/experimental-durable-event-iterator@854

@orpc/hey-api

npm i https://pkg.pr.new/@orpc/hey-api@854

@orpc/json-schema

npm i https://pkg.pr.new/@orpc/json-schema@854

@orpc/json-schema-typed

npm i https://pkg.pr.new/@orpc/json-schema-typed@854

@orpc/nest

npm i https://pkg.pr.new/@orpc/nest@854

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@854

@orpc/openapi-client

npm i https://pkg.pr.new/@orpc/openapi-client@854

@orpc/otel

npm i https://pkg.pr.new/@orpc/otel@854

@orpc/react

npm i https://pkg.pr.new/@orpc/react@854

@orpc/react-query

npm i https://pkg.pr.new/@orpc/react-query@854

@orpc/server

npm i https://pkg.pr.new/@orpc/server@854

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@854

@orpc/solid-query

npm i https://pkg.pr.new/@orpc/solid-query@854

@orpc/standard-server

npm i https://pkg.pr.new/@orpc/standard-server@854

@orpc/standard-server-aws-lambda

npm i https://pkg.pr.new/@orpc/standard-server-aws-lambda@854

@orpc/standard-server-fetch

npm i https://pkg.pr.new/@orpc/standard-server-fetch@854

@orpc/standard-server-node

npm i https://pkg.pr.new/@orpc/standard-server-node@854

@orpc/standard-server-peer

npm i https://pkg.pr.new/@orpc/standard-server-peer@854

@orpc/svelte-query

npm i https://pkg.pr.new/@orpc/svelte-query@854

@orpc/tanstack-query

npm i https://pkg.pr.new/@orpc/tanstack-query@854

@orpc/trpc

npm i https://pkg.pr.new/@orpc/trpc@854

@orpc/valibot

npm i https://pkg.pr.new/@orpc/valibot@854

@orpc/vue-colada

npm i https://pkg.pr.new/@orpc/vue-colada@854

@orpc/vue-query

npm i https://pkg.pr.new/@orpc/vue-query@854

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@854

commit: da3e723

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 overrides

If 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 suggestions

The 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 initialization

Initialization 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

📥 Commits

Reviewing files that changed from the base of the PR and between 37971b1 and 7b57284.

📒 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 good

EncodeHibernationRPCEventOptions 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; no experimental_ prefixes remain
All experimental_… symbols have been removed, and the core hibernation exports are correctly re-exported from packages/server/src/hibernation/index.ts:

  • encodeHibernationRPCEvent (via export * from './event-iterator')
  • HibernationEventIterator & HibernationEventIteratorCallback (via export { … } from '@orpc/standard-server')
  • HibernationPlugin (via export * 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 symbol

Import 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: good

Using 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 adopted

Importing 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 adopted

HibernationPlugin 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 iterator

Directly importing HibernationEventIterator keeps tests aligned with the stabilized API.

packages/server/src/hibernation/plugin.test.ts (2)

1-1: Use of canonical HibernationEventIterator in test

Import updated to the stable symbol from @orpc/standard-server. Good alignment with the new API.


4-4: HibernationPlugin import stabilization

Importing 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 correct

Switched 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 HibernationEventIterator

Aligns 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 export

Directly 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 rename

The 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-server

This 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 HibernationEventIterator

Import aligns with the new canonical class location. OK.


6-8: Public context type rename

Exported HibernationPluginContext looks good and keeps type surface stable post-rename.


15-15: Plugin class rename to HibernationPlugin

Matches docs and re-exports. No functional differences introduced.


49-49: Context retrieval via symbol

Looks correct; throws early if the context was corrupted. This keeps failures explicit.


57-59: instanceof check targeting stable iterator class

The 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.

@dinwwwh dinwwwh merged commit a320605 into main Aug 11, 2025
7 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant