Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/server/src/hibernation/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Context } from '../context'
import type { Router } from '../router'
import { experimental_HibernationEventIterator } from '@orpc/standard-server'

export interface experimental_HibernationContext {
export interface experimental_HibernationPluginContext {
iterator?: experimental_HibernationEventIterator<any>
}

Expand All @@ -13,7 +13,7 @@ export interface experimental_HibernationContext {
* @see {@link https://orpc.unnoq.com/docs/plugins/hibernation Hibernation Plugin}
*/
export class experimental_HibernationPlugin<T extends Context> implements StandardHandlerPlugin<T> {
readonly HIBERNATION_CONTEXT_SYMBOL = Symbol('HIBERNATION_CONTEXT')
readonly CONTEXT_SYMBOL = Symbol('ORPC_HIBERNATION_CONTEXT')

order = 2_000_000 // make sure execute after the batch plugin

Expand All @@ -22,12 +22,12 @@ export class experimental_HibernationPlugin<T extends Context> implements Standa
options.clientInterceptors ??= []

options.interceptors.unshift(async (options) => {
const hibernationContext: experimental_HibernationContext = {}
const hibernationContext: experimental_HibernationPluginContext = {}

const result = await options.next({
...options,
context: {
[this.HIBERNATION_CONTEXT_SYMBOL]: hibernationContext,
[this.CONTEXT_SYMBOL]: hibernationContext,
...options.context,
},
})
Expand All @@ -46,7 +46,7 @@ export class experimental_HibernationPlugin<T extends Context> implements Standa
})

options.clientInterceptors.unshift(async (options) => {
const hibernationContext = options.context[this.HIBERNATION_CONTEXT_SYMBOL] as experimental_HibernationContext | undefined
const hibernationContext = options.context[this.CONTEXT_SYMBOL] as experimental_HibernationPluginContext | undefined

if (!hibernationContext) {
throw new TypeError('[HibernationPlugin] Hibernation context has been corrupted or modified by another plugin or interceptor')
Expand Down