grpc/grpc-node

Getting error when trying to get missing field

ArtTemiy opened this issue · 1 comments

Hello! I was trying to get a missing field of a message and expected to receive a undefind, but got an error saying TypeError: Cannot read properties of null (reading '10') (number for corresponding field).
Turned out that the problem occurred because wrappers_ field of the message was equal to null. In the jspb.Message.getWrapperField there is check to prevent it, looking like a.wrappers_ || (a.wrappers_ = {});. But for some strange reason that doesn't work and assignment left wrapper_ filed with null (I was trying to make it by myself before calling getMyField, it still didn't help).

I receive the "invalid" message from server, thats why wrappers_ set to null (if I create it with new MyMessage wrappers_ is set to {} and everything works fine)

It looks like you're talking about the API of code generated with grpc-tools. We don't control the message code generation, we just redistribute it. That code lives in this repository so you're more likely to get answers there. However, note that the version distributed in grpc-tools is out of date, so it is possible that this problem has been fixed there and we haven't picked up the fix.