Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES3 protobuf - getRepeatedWrapperField & wrapRepeatedField_ #24

Open
prk68 opened this issue Aug 28, 2020 · 6 comments
Open

ES3 protobuf - getRepeatedWrapperField & wrapRepeatedField_ #24

prk68 opened this issue Aug 28, 2020 · 6 comments
Assignees
Labels

Comments

@prk68
Copy link

prk68 commented Aug 28, 2020

I am trying to run protbuf serialization for JScript app that runs in a window scripting host runtime (WSH) on window. The JScript seems to based on a very old version of Ecmascript.

I webpacked my app code and ran into following error

"length is null or not an object"

for this line

for (var d = jspb.Message.getRepeatedField(a, c), e = [], f = 0; f < d.length; f++)

This seeems to be happening inside wrapRepeatedField_ function from a getRepeatedWrapperField call.

The same webpacked application code runs perfectly fine on chrome browser. So I am suspecting an issue either with missing polyfills because of which the message was not initialized properly.

I would appreciate any hints on how I could make this work on this old JScript runtime.

@prk68
Copy link
Author

prk68 commented Aug 28, 2020

Further logging tells me that this happens because jspb.Message.getField returns undefined. Both the following conditions do not match
if (b < a.pivot_)

if (a.extensionObject_)

@jelleklaver
Copy link

jelleklaver commented Sep 24, 2020

Hi @prk68,

I seem to have a similar issue, but it occurs to me running in both Chrome and Firefox. I've been using protobuf with grpc-web for a while now, and it suddenly occured for a particular definition. Both errors point to the same line as you mentioned. I use parcel to generate the client code.

// Chrome console
TypeError: Cannot read property 'length' of undefined
    at Function.jspb.Message.wrapRepeatedField_ (google-protobuf.js:432)
    at Function.jspb.Message.getRepeatedWrapperField (google-protobuf.js:432)
    at proto.domain.Question.getAnswersList (domain_pb.js:4651)
    ...
// Firefox console
TypeError: d is undefined
    wrapRepeatedField_ google-protobuf.js:432
    getRepeatedWrapperField google-protobuf.js:432
    getAnswersList domain_pb.js:4651
    ...

I tried to regenerate the javascript files using protoc 3.12.4 and 3.13.0 and grpc-web 1.2.0 and 1.2.1, but both give the same results. The strange thing is, that it seems that sometimes setting the repeated field as an empty array (.setAnswersList([])) helps, and sometimes it doesn't.

I'm pretty clueless in how to debug this further. Did you find a solution?

@shaod2 shaod2 self-assigned this Oct 22, 2020
@Elojah
Copy link

Elojah commented Apr 9, 2021

Any news on this bug ? I have exactly the same as @jelleklaver, i can reproduce to give more informations if necessary.
Proto definition:

message FooResp {
    repeated foo.Bar MyField = 1;
}

(with foo.Bar containing only native strings)

@jelleklaver
Copy link

Hi @Elojah, we came across this again this week and we just figured out what happened in our case. Our protobuf definitions rely on a shared domain.proto, but with grpc-web we cannot use this as a single library (grpc/grpc-web#776). The issue was that we regenerated one library with grpc-web, but in-code we referenced this shared dependency from another library. So the repeated field didn't exist in the referenced code.

Therefore, it was an issue on our side. I think a more readable error message like field x doesn't exist would massively improve the debugging experience here. I don't know if this helps you in any way @Elojah, but there's no more I know.

@Elojah
Copy link

Elojah commented Apr 14, 2021

Same on my side, protobuf files were not generated for typescript grpc-web but only typescript (without those fields, actually just a generation option to change). Thanks for the follow up @jelleklaver , and sorry for the false bug report.

@acozzette acozzette transferred this issue from protocolbuffers/protobuf May 16, 2022
@dibenede
Copy link
Contributor

dibenede commented Sep 2, 2022

This sounds like a versioning issue and we might have something we can upstream to help out in the future.

@dibenede dibenede added the triaged Issue has been triaged label Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants