MCPcopy
hub / github.com/blitz-js/blitz / invokeWithCtx

Function invokeWithCtx

packages/blitz-rpc/src/server/plugin.ts:41–57  ·  view source on GitHub ↗
(
    queryFn: T,
    params: TInput,
  )

Source from the content-addressed store, hash-verified

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: () => ({

Callers

nothing calls this directly

Calls 2

errorMethod · 0.95
invokeFunction · 0.90

Tested by

no test coverage detected