{"id":"791ef530662401a0","repo":"nestjs/nest","slug":"method-is-not-supported-in-grpc-mode-791ef5","errorCode":null,"errorMessage":"Method is not supported in gRPC mode.","messagePattern":"Method is not supported in gRPC mode\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/microservices/server/server-grpc.ts","lineNumber":340,"sourceCode":"          const handler = methodHandler(call.request, call.metadata, call);\n          const result$ = this.transformToObservable(await handler);\n          await this.writeObservableToGrpc(result$, call);\n\n          this.onProcessingEndHook?.(this.transportId, call.request);\n        },\n      );\n    };\n  }\n\n  public unwrap<T>(): T {\n    throw new Error('Method is not supported for gRPC transport');\n  }\n\n  public on<\n    EventKey extends string | number | symbol = string | number | symbol,\n    EventCallback = any,\n  >(event: EventKey, callback: EventCallback) {\n    throw new Error('Method is not supported in gRPC mode.');\n  }\n\n  /**\n   * Writes an observable to a GRPC call.\n   *\n   * This function will ensure that backpressure is managed while writing values\n   * that come from an observable to a GRPC call.\n   *\n   * @param source The observable we want to write out to the GRPC call.\n   * @param call The GRPC call we want to write to.\n   * @returns A promise that resolves when we're done writing to the call.\n   */\n  private writeObservableToGrpc<T>(\n    source: Observable<T>,\n    call: GrpcCall<T>,\n  ): Promise<void> {\n    // This promise should **not** reject, as we're handling errors in the observable for the Call\n    // the promise is only needed to signal when writing/draining has been completed","sourceCodeStart":322,"sourceCodeEnd":358,"githubUrl":"https://github.com/nestjs/nest/blob/6ec0e2783d15290732447f304d8549b591b9749e/packages/microservices/server/server-grpc.ts#L322-L358","documentation":"Error \"Method is not supported in gRPC mode.\" thrown in nestjs/nest.","triggerScenarios":"Thrown at packages/microservices/server/server-grpc.ts:340 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Do not call this method on a gRPC server instance; gRPC transport does not support it.","Use the ServerGrpc-specific API (e.g. getClient/getService) or a transport that supports the operation instead.","Remove the call from code paths that run when the microservice uses Transport.GRPC."],"exampleFix":"// Guard by transport before calling unsupported methods\nif (app.get(MicroserviceOptions).transport !== Transport.GRPC) {\n  server.on('error', handler);\n}","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"6ec0e2783d15290732447f304d8549b591b9749e","analyzedAt":"2026-08-03T17:42:23.673Z","schemaVersion":2}