Nest: [gRPC] Loader option causes ClientGrpc.getService fail

Created on 28 Aug 2018  路  11Comments  路  Source: nestjs/nest

https://github.com/nestjs/nest/blob/d0bd2f7b200ebae72b29bc6b5fc3d62db81cd8fc/packages/microservices/client/client-grpc.ts#L36

(node:1600) UnhandledPromiseRejectionWarning: TypeError: Channel options must be an object with string keys and integer or string values

The message is pretty clear on what causes it. Right now my workaround is removing loader attribute before passing it to the constructor.

microservices potential issue 馃挃

Most helpful comment

Thanks @dzzzzzy. Looks like only the Client throws an exception when loader option is passed. Just published 5.3.7 fix :)

All 11 comments

Could you share your entire loader options?

@kamilmysliwiec Sure, here it is

loader: { includeDirs: [join(__dirname, process.env.PROTOS_PATH || '')] }

Honestly, just tried your code and I cannot reproduce your issue. Do you use the latest version of the framework?

i have the same issue when set loader, solutions:

  1. use absolute path for protoPath;
  2. don't pass loader property in nestjs client-grpc getService method.

@kamilmysliwiec I did at the time. It was 5.2.2. I haven't tried again with the new version yet.

@nooop3 I need it because of the imports in protobuf files.

Problem still persists with version 5.3.6

@Client({
        transport: Transport.GRPC,
        options: {
            url: 'localhost:50051',
            package: 'notadd_module_user',
            protoPath: join(__dirname, './protobufs/user-module.proto'),
            loader: {
                arrays: true
            }
        }
    })
    public readonly userModuleClient: ClientGrpc;

same error:

Channel options must be an object with string keys and integer or string values

@kamilmysliwiec hello kamil, the loader options can not work on @Client with grpc, could you give me some help?

[System Information]
OS Version     : Linux 4.18
NodeJS Version : v10.7.0
YARN Version    : 1.9.4
[Nest Information]
microservices version : 5.3.6
graphql version       : 5.2.2
common version        : 5.3.6
core version          : 5.3.6

Hi guys,
I really need the whole repo with dir structure. I can't reproduce this issue without it

Hi guys,
I really need the whole repo with dir structure. I can't reproduce this issue without it

@kamilmysliwiec Here is the reproduce repo with nest sample-04-grpc https://github.com/dzzzzzy/nest/tree/master/sample/04-grpc

I do these changes:

  1. update the core, common and microservice package to latest version
  2. add loader options to grpc-client.options.ts such as:
loader: {
      arrays: true,
      keepCase: true,
      longs: String,
      enums: String,
      defaults: true,
      oneofs: true
    }

And then run npm start, this issues can reproduced.

Thanks @dzzzzzy. Looks like only the Client throws an exception when loader option is passed. Just published 5.3.7 fix :)

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rlesniak picture rlesniak  路  3Comments

anyx picture anyx  路  3Comments

thohoh picture thohoh  路  3Comments

menme95 picture menme95  路  3Comments

artaommahe picture artaommahe  路  3Comments