最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - TypeError: Cannot read properties of undefined (reading 'MethodInfo') in react js app using grpc-we

programmeradmin10浏览0评论

I am using grpc-web to communicate with a java backend over gRPC. I am using ReactJS on the frontend which uses grpc-web to interpret the protobuffers.

I am getting this strange error. My protos are correct ( I checked using a reflection tool called "bloom" so the backend is just fine) This somehow seems like an error internal to the grpc libraries I am using in ReactJS.

I get the following error:

TypeError: Cannot read properties of undefined (reading 'MethodInfo')

The above error points to my proto file: dashboard_services_grpc_web_pb.js

In this file, it point to this line

const methodInfo_DashboardService_userLogin = new grpc.web.AbstractClientBase.MethodInfo( ...... );

I have a hard time solving this because according to my understanding, grpc.web.AbstractClientBase is something native to grpc-web.

I have also reinstalled my node_modules in hopes that this is a version issue but no avail.

I am using grpc-web to communicate with a java backend over gRPC. I am using ReactJS on the frontend which uses grpc-web to interpret the protobuffers.

I am getting this strange error. My protos are correct ( I checked using a reflection tool called "bloom" so the backend is just fine) This somehow seems like an error internal to the grpc libraries I am using in ReactJS.

I get the following error:

TypeError: Cannot read properties of undefined (reading 'MethodInfo')

The above error points to my proto file: dashboard_services_grpc_web_pb.js

In this file, it point to this line

const methodInfo_DashboardService_userLogin = new grpc.web.AbstractClientBase.MethodInfo( ...... );

I have a hard time solving this because according to my understanding, grpc.web.AbstractClientBase is something native to grpc-web.

I have also reinstalled my node_modules in hopes that this is a version issue but no avail.

Share Improve this question edited Oct 15, 2021 at 10:01 Asma Rahim Ali Jafri asked Oct 14, 2021 at 12:53 Asma Rahim Ali JafriAsma Rahim Ali Jafri 1,3833 gold badges17 silver badges22 bronze badges 6
  • I have also cleared my npm cache both internally and globally by running npm cache clean --force – Asma Rahim Ali Jafri Commented Oct 14, 2021 at 13:32
  • I also cloned the project into a new directory in hopes that it must be some caching issue – Asma Rahim Ali Jafri Commented Oct 14, 2021 at 13:33
  • 1 Your title mentions grpc-js. How is grpc-js involved here? – murgatroid99 Commented Oct 14, 2021 at 21:15
  • it was installed in the project so I thought it could be worth mentioning @murgatroid99 – Asma Rahim Ali Jafri Commented Oct 15, 2021 at 6:31
  • OK, are you using it in some way that relates to this question, and if so, how? – murgatroid99 Commented Oct 15, 2021 at 6:57
 |  Show 1 more comment

2 Answers 2

Reset to default 10

I had the same issue because I was using an old release of the executable protoc-gen-grpc-web with respect to the current version of grpc-web. Using version 1.3.0 for both solved the issue for me. You can download the latest release of protoc-gen-grpc-web here.

In my case it was happening after cache clear, because we had:

"grpc-web": "^1.2.1",

and it was installed version 1.3.0 I changed it to:

"grpc-web": "1.2.1",

and yarn again to fix this issue!

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论