简体   繁体   English

类型错误:无法使用 grpc-web 在 react js 应用程序中读取未定义的属性(读取“MethodInfo”)

[英]TypeError: Cannot read properties of undefined (reading 'MethodInfo') in react js app using grpc-web

I am using grpc-web to communicate with a java backend over gRPC.我正在使用 grpc-web 通过 gRPC 与 java 后端通信。 I am using ReactJS on the frontend which uses grpc-web to interpret the protobuffers.我在前端使用 ReactJS,它使用 grpc-web 来解释 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.我的原型是正确的(我使用名为“bloom”的反射工具进行了检查,因此后端很好)这在某种程度上似乎是我在 ReactJS 中使用的 grpc 库的内部错误。

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上面的错误指向我的 proto 文件: 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 .我很难解决这个问题,因为根据我的理解, grpc.web.AbstractClientBasegrpc-web原生的东西。

I have also reinstalled my node_modules in hopes that this is a version issue but no avail.我还重新安装了我的 node_modules,希望这是一个版本问题,但无济于事。

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 .我遇到了同样的问题,因为我使用的是旧版本的可执行文件protoc-gen-grpc-web相对于当前版本的grpc-web Using version 1.3.0 for both solved the issue for me.使用 1.3.0 版为我解决了这个问题。 You can download the latest release of protoc-gen-grpc-web here .您可以在此处下载protoc-gen-grpc-web的最新版本。

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:它安装了1.3.0版,我将其更改为:

"grpc-web": "1.2.1",

and yarn again to fix this issue!yarn再次解决这个问题!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TypeError:无法读取未定义的属性(读取“地图”)React JS - TypeError: Cannot read properties of undefined (reading 'map') React JS TypeError:无法在 React Js 中读取未定义的属性(读取“推送”) - TypeError: Cannot read properties of undefined (reading 'push') in React Js TypeError:无法在反应 JS 中读取未定义的属性(读取“地图”) - TypeError: Cannot read properties of undefined (reading 'map') in react JS TypeError:无法读取未定义的属性(读取'noticeNo')React.js - TypeError: Cannot read properties of undefined (reading 'noticeNo') React.js REACT JS - TypeError:无法读取未定义的属性(读取“名称”) - REACT JS - TypeError: Cannot read properties of undefined (reading 'name') TypeError:无法在 React js 中读取未定义的属性(读取“参数”) - TypeError: Cannot read properties of undefined (reading 'params') in React js TypeError:无法读取未定义的属性(读取“用户名”):React js - TypeError: Cannot read properties of undefined (reading 'userName') : React js TypeError:无法读取未定义的属性(读取“原型”)React APP - TypeError: Cannot read properties of undefined (reading 'prototype') React APP 类型错误:无法使用 Axios 在 React 中读取未定义的属性(读取“协议”) - TypeError: Cannot read properties of undefined (reading 'protocol') in React using Axios TypeError:无法读取未定义(读取“过滤器”)和未定义错误的属性 - React - TypeError: Cannot read properties of undefined (reading 'filter') and undefined error - React
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM