| 39 | globalThis.blitzRpcRpcLoggerOptions = options.logging |
| 40 | } |
| 41 | async function invokeWithCtx<T extends (...args: any) => any, TInput = FirstParam<T>>( |
| 42 | queryFn: T, |
| 43 | params: TInput, |
| 44 | ): Promise<PromiseReturnType<T>> { |
| 45 | const ctx = await globalThis.__BLITZ_GET_RSC_CONTEXT() |
| 46 | try { |
| 47 | return await invoke(queryFn, params, ctx, options.logging) |
| 48 | } catch (error) { |
| 49 | if (options.onInvokeError) { |
| 50 | options.onInvokeError(error) |
| 51 | } else { |
| 52 | const rpcLogger = new RpcLogger((queryFn as any)._resolverName, options.logging) |
| 53 | rpcLogger.error(error) |
| 54 | } |
| 55 | throw error |
| 56 | } |
| 57 | } |
| 58 | return { |
| 59 | requestMiddlewares: [] as RequestMiddleware<any, any, void | Promise<void>>[], |
| 60 | exports: () => ({ |