nest icon indicating copy to clipboard operation
nest copied to clipboard

Calling start() on grpc client throws DeprecationWarning after @grpc/grpc-js v1.10.0

Open deekthesqueak opened this issue 1 year ago • 0 comments
trafficstars

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current behavior

When using a grpc based microservice with @grpc/grpc-js v1.10.0 or greater will cause a DeprecationWarning to be thrown when start() is called.

The @grpc/grpc-js package was updated from v1.9.14 to v1.10.0 with release v10.3.2 via PR #13173

https://github.com/grpc/grpc-node/blob/9886ee2da71ead90f61fb0d6688abb56525a60fd/packages/grpc-js/src/server.ts#L981-L984

(node:30234) DeprecationWarning: Calling start() is no longer necessary. It can be safely omitted.
    at ServerGrpc.start (/home/local/project/node_modules/@nestjs/microservices/server/server-grpc.js:38:25)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at ServerGrpc.listen (/home/local/project/node_modules/@nestjs/microservices/server/server-grpc.js:30:13)

Minimum reproduction code

https://github.com/nestjs/nest/blob/v10.3.8/sample/04-grpc

Steps to reproduce

  1. cd nest/sample/04-grpc
  2. npm install
  3. update src/grpc-client.options.ts to contain
import { ClientOptions, Transport } from '@nestjs/microservices';
import { join } from 'path';

export const grpcClientOptions: ClientOptions = {
  transport: Transport.GRPC,
  options: {
    package: 'hero',
    protoPath: join(__dirname, './hero/hero.proto')
  },
};
  1. npm run start:dev
  2. Observe startup and error

Expected behavior

When using @grpc/grpc-js v1.10.0 or greater with nestjs v10.3.2 or greater no DeprecationWarning is thrown

Package

  • [ ] I don't know. Or some 3rd-party package
  • [ ] @nestjs/common
  • [ ] @nestjs/core
  • [X] @nestjs/microservices
  • [ ] @nestjs/platform-express
  • [ ] @nestjs/platform-fastify
  • [ ] @nestjs/platform-socket.io
  • [ ] @nestjs/platform-ws
  • [ ] @nestjs/testing
  • [ ] @nestjs/websockets
  • [ ] Other (see below)

Other package

No response

NestJS version

10.3.8

Packages versions

{
  "name": "nest-typescript-starter",
  "version": "1.0.0",
  "description": "Nest TypeScript starter repository",
  "license": "MIT",
  "scripts": {
    "prebuild": "rimraf dist",
    "build": "nest build",
    "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
    "start": "nest start",
    "start:dev": "nest start --watch",
    "start:debug": "nest start --debug --watch",
    "start:prod": "node dist/main",
    "lint": "eslint '{src,apps,libs,test}/**/*.ts' --fix",
    "test": "jest",
    "test:watch": "jest --watch",
    "test:cov": "jest --coverage",
    "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
    "test:e2e": "echo 'No e2e tests implemented yet.'"
  },
  "dependencies": {
    "@grpc/grpc-js": "1.10.0",
    "@grpc/reflection": "1.0.3",
    "@nestjs/common": "10.3.2",
    "@nestjs/core": "10.3.2",
    "@nestjs/microservices": "10.3.2",
    "@nestjs/platform-express": "10.3.2",
    "class-transformer": "0.5.1",
    "class-validator": "0.14.1",
    "reflect-metadata": "0.2.1",
    "rimraf": "5.0.5",
    "rxjs": "7.8.1"
  },
  "devDependencies": {
    "@nestjs/cli": "10.3.2",
    "@nestjs/schematics": "10.1.1",
    "@nestjs/testing": "10.3.2",
    "@types/express": "4.17.21",
    "@types/node": "20.8.7",
    "@types/supertest": "2.0.16",
    "@typescript-eslint/eslint-plugin": "5.62.0",
    "@typescript-eslint/parser": "5.62.0",
    "eslint": "8.42.0",
    "eslint-config-prettier": "9.1.0",
    "eslint-plugin-import": "2.29.1",
    "jest": "29.7.0",
    "prettier": "3.2.5",
    "supertest": "6.3.3",
    "ts-jest": "29.1.2",
    "ts-loader": "9.5.1",
    "ts-node": "10.9.2",
    "tsconfig-paths": "4.2.0",
    "typescript": "5.3.3"
  }
}

Node.js version

20.11.0

In which operating systems have you tested?

  • [X] macOS
  • [ ] Windows
  • [x] Linux

Other

No response

deekthesqueak avatar May 06 '24 04:05 deekthesqueak