0

I have a grpc-js server setup with a rpc method called getUsers(). When making the call from the client, I only receive 4 of the messages back, despite there being 6 sent.

Here's the client method:

const client = new UsersClient(environment.rpcHost);
    const params = new CMSQuery();
    client.getUsers(params).on('data', (message: User) => {
      const obj = message.toObject();
      console.log(`${obj.name} received`);
      this.users.push(obj);
    }).on('end', () => {
      console.log('End of request');
    });

And here's the server method:

    async getUsers(call: grpc.ServerWritableStream<CMSQuery, User>): Promise<any> {
        const params = call.request.toObject();
        this.collection.find({}).forEach(user => {
            const message = protoFromObject(User, user);
            call.write(message);
            console.log(`${user.name} sent`);
        }).finally(() => {
            console.log('Closing request');
            call.end();
        });
    }

The server has the following console output:

User1 sent
User2 sent
User3 sent
User4 sent
User5 sent
User6 sent
Closing Request

And yet the client only has the following console output:

User1 received
User2 received
User3 received
User4 received
End of request

Are there any obvious things that would cause this? Some sort of timeout? Can anyone give me some pointers as to where I should be looking as I'm really stuck at the moment.

Thanks

Tom
  • 47
  • 6
  • This sounds like something you should report on the grpc-js repository itself in the form of a reproducible bug: https://github.com/grpc/grpc-node/issues/new?assignees=&labels=&template=bug_report.md – Nicolas Noble Feb 03 '21 at 18:55
  • @Nicholas Noble, Turns out there was an assertion error that was being suppressed, once I fixed the data type in one of the users being emitted, the error was resolved. – Tom Feb 05 '21 at 11:56

0 Answers0