-
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
Make Message.prototype.toObject({defaults: true})
use undefined instead of null?
#658
Comments
Have you tried with 6.6.1 already? |
No.. didn't find relevant info in the release notes, so I thought it wasn't fixed. I'll try asap, thanks! |
Might not be fixed in 6.6.1, just asking. Feel free to reopen if it's still an issue! |
…c.; Fixed: Make sure to check optional inner messages for null when encoding, see #658
Just got time to test it, and sadly it wasn't fixed in 6.6.1. It seems 2b12fb7 took care of it, when would it be released? Also, 6.6.1 seems to be forcing Long.js for me when using the light build (with webpack setup).. import Service from 'protobufjs/src/service';
import Type from 'protobufjs/src/type';
import Namespace from 'protobufjs/src/namespace';
import ReflectionObject from 'protobufjs/src/object';
import Root from 'protobufjs/src/root';
import BufferReader from 'protobufjs/src/reader_buffer';
import Reader from 'protobufjs/src/reader';
Reader._configure(BufferReader);
Namespace._configure(Type, Service);
ReflectionObject._configure(Root);
Namespace._configure(Type, Service);
Root._configure(Type);
// finally
var root = Root.fromJSON(json);
var service = Root.lookup('......'); Should I open a separate issue? |
Probably soon™.
Hmm, that shouldn't happen. There shouldn't be a place anymore where long.js is required explicitly. Instead, it's loaded dynamically. Any ideas? |
Cause: |
Ah, right, the AMD loader. Hrm... |
Why was Long.js required by default in index-minimal though? I though it was optional and easy-opt-in with |
Well, it IS meant to be optional. With the inquire thing in place, browserify does not include long by default because it doesn't evaluate AMD loaders at all. That's how it is intended. Webpack, on the other hand, evaluates the AMD loader shim (in full, light and minimal alike), even though a loader like require.js wouldn't throw if long isn't actually present. You could still exclude it from your project through respective webpack config stuff, or wait until I move the AMD shim out of source to the dist wrapper, which I haven't done yet because browserify doesn't offer a way to specify a custom prelude. |
Well, I though if it's optional then it may be all right to just not include it at all, and put a notice in the docs about using |
It's not that easy actually because there is some reconfiguration taking place when Long is installed (perf reasons). |
Ah, right... missed that part. Maybe Reader can expose a method to use Long explicitly then? Something like |
I just figured out how to use a custom browserify prelude. Once that's in place, we can remove the define call from source. |
For reference: prelude As you see there, long.js can also be installed manually through assigning it first and then calling |
Feel free to reopen if there are still any issues! |
protobuf.js version: 6.5.0
I'm trying to send an object that's converted from a message (via
toObject({defaults: true})
) back to server, but I got something like:The messages looks like
and the js
It was working perfectly fine before 6.5.0. Seems to be caused by the generated code only checking for
undefined
but notnull
.So maybe we can make
toObject
useundefined
instead of null? Or let the generated code check for bothnull
andundefined
?The text was updated successfully, but these errors were encountered: