protobuf.js version: 6.6.3
Calling .toObject with the Number option for longs is returning a value that's incorrect, at least for very large Longs (in our case, an epoch). Strangely, the result is different than calling toNumber on the specific field. Calling proto.toObject({ longs: Number }) is resulting in a different value than proto.longValue.toNumber().
The relevant shape of the object is:
const proto = {
innerProto: {
timestampMs: {
low: -2114947712,
high: 346,
unsigned: true,
},
},
};
// Calling toObject we get the following
const converted = proto.toObject({ longs: Number });
console.log(converted.innerProto.timestampMs); // 1483943736704
// vesus...
console.log(proto.innerProto.timestampMs.toNumber()); // 1488238704000
protobuf.js version: 6.6.3
Calling
.toObjectwith theNumberoption forlongsis returning a value that's incorrect, at least for very largeLongs(in our case, an epoch). Strangely, the result is different than callingtoNumberon the specific field. Callingproto.toObject({ longs: Number })is resulting in a different value thanproto.longValue.toNumber().The relevant shape of the object is: