-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Bug: .encode
doesn't work properly on nested oneof members.
#583
Comments
Here, you are creating a runtime message for D, but using a plain object for C. Plain objects do not have virtual oneof properties so the encoder cannot efficiently know which field is present: var d_message = D.create({
c: {
a: {
b: 10
}
}
}); This should work: var d_message = D.create({
c: {
a: {
b: 10
},
child: "a"
}
}); Or this: var d_message = D.create({
c: C.create({
a: {
b: 10
}
})
}); |
I just tested your version of the code and it seems to work just fine. 👍 |
The empty buffer you see there might be related to #581 - or does this also happen with master? |
Also, with master, it should be possible to use var d_message = D.from({
c: {
a: {
b: 10
}
}
}); Related: #575 |
Checked on |
protobuf.js version: 6.2.1
Encoding message that includes nested oneof elements results in an empty buffer.
Using the following protobuf as an example:
And the relevant js
The resulting buffer will be empty.
In this version however it does work
The following jsfiddle snippet shows the error, printed to console
https://jsfiddle.net/ju7h93rr/
The followign jsfiddle snippet shows a modified version in which it works as expected
https://jsfiddle.net/2tvqLtLo/
The text was updated successfully, but these errors were encountered: