grpc / grpc/grpc-node

Getting error when trying to get missing field

Open
#2,725 1 comment 0 reactions 0 assignees View on GitHub
package: grpc-tools
Dominant language
TypeScript
Stars
4.8k
Forks
716
Avg merge
2d 3h
Merged PRs (30d)
10

Description

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)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.