{"id":"230ade5cb83c50c5","repo":"nestjs/nest","slug":"method-is-not-supported-in-grpc-mode-use-clientgr","errorCode":null,"errorMessage":"Method is not supported in gRPC mode. Use ClientGrpc instead (learn more in the documentation).","messagePattern":"Method is not supported in gRPC mode\\. Use ClientGrpc instead \\(learn more in the documentation\\)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/microservices/client/client-grpc.ts","lineNumber":369,"sourceCode":"  public close() {\n    this.clients.forEach(client => {\n      if (client && isFunction(client.close)) {\n        client.close();\n      }\n    });\n    this.clients.clear();\n    this.grpcClients = [];\n  }\n\n  public async connect(): Promise<any> {\n    throw new Error('The \"connect()\" method is not supported in gRPC mode.');\n  }\n\n  public send<TResult = any, TInput = any>(\n    pattern: any,\n    data: TInput,\n  ): Observable<TResult> {\n    throw new Error(\n      'Method is not supported in gRPC mode. Use ClientGrpc instead (learn more in the documentation).',\n    );\n  }\n\n  protected getClient(name: string): any {\n    return this.grpcClients.find(client =>\n      Object.hasOwnProperty.call(client, name),\n    );\n  }\n\n  protected publish(packet: any, callback: (packet: any) => any): any {\n    throw new Error(\n      'Method is not supported in gRPC mode. Use ClientGrpc instead (learn more in the documentation).',\n    );\n  }\n\n  protected async dispatchEvent(packet: any): Promise<any> {\n    throw new Error(","sourceCodeStart":351,"sourceCodeEnd":387,"githubUrl":"https://github.com/nestjs/nest/blob/6ec0e2783d15290732447f304d8549b591b9749e/packages/microservices/client/client-grpc.ts#L351-L387","documentation":"`ClientGrpcProxy.send(pattern, data)` throws because the request/response pattern-messaging API does not apply to gRPC. gRPC uses typed service clients obtained via `getService(name)`. The message directs you to use the `ClientGrpc` interface instead of `ClientProxy.send`.","triggerScenarios":"Calling `clientGrpc.send('pattern', payload)` instead of `clientGrpc.getService('ServiceName').method(payload)`.","commonSituations":"Treating a gRPC client like `ClientTCP`/`ClientRedis`/`ClientNats`; copy-paste messaging code from another transport; switching transport without rewriting the call site.","solutions":["Replace `send(pattern, data)` with `getService<T>('Svc').method(data)`.","Define a TypeScript interface mirroring the proto service for type-safe calls.","Audit all `send`/`emit` usages when migrating to gRPC."],"exampleFix":"// before\nclient.send('sum', { data: [1, 2] }).subscribe(r => console.log(r));\n// after\nconst math = client.getService<MathClient>('Math');\nmath.sum({ data: [1, 2] }).subscribe(r => console.log(r));","handlingStrategy":"type-guard","validationCode":"import { ClientGrpc } from '@nestjs/microservices';\nfunction useGrpcService<T>(c: ClientGrpc, name: string): T {\n  return c.getService<T>(name);\n}\nconst math = useGrpcService<MathClient>(client, 'Math');","typeGuard":"import { ClientGrpc } from '@nestjs/microservices';\nfunction isGrpcClient(c: unknown): c is ClientGrpc {\n  return typeof c === 'object' && c !== null && typeof (c as any).getService === 'function';\n}","tryCatchPattern":null,"preventionTips":["Replace any `client.send(...)` call with `getService<T>().method(...)` when migrating to gRPC.","Define TypeScript interfaces mirroring the proto service.","Lint against `.send(`/`.emit(` on `ClientGrpc` instances."],"tags":["grpc","microservices","client-proxy","api-misuse","nestjs"],"analyzedSha":"6ec0e2783d15290732447f304d8549b591b9749e","analyzedAt":"2026-08-03T17:42:23.673Z","schemaVersion":2}