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

toObject with large long type is returning a wrong value #690

Closed
yoni-tock opened this issue Feb 27, 2017 · 6 comments
Closed

toObject with large long type is returning a wrong value #690

yoni-tock opened this issue Feb 27, 2017 · 6 comments
Labels

Comments

@yoni-tock
Copy link

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
@robin-anil
Copy link
Contributor

@dcodeIO Please prioritize this, we have a customer escalation due to this.

@dcodeIO
Copy link
Member

dcodeIO commented Feb 28, 2017

Please let me know if this solves your issue!

@dcodeIO dcodeIO added the bug label Feb 28, 2017
@robin-anil
Copy link
Contributor

@dcodeIO Yes could you also push a new minor release. Thanks again for the fast fix.

@yoni-tock
Copy link
Author

@dcodeIO Thanks so much! This resolved the issue we were seeing.

@dcodeIO
Copy link
Member

dcodeIO commented Feb 28, 2017

Now on npm!

@raojs
Copy link

raojs commented Mar 6, 2017

Repair very timely, very grateful.

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

4 participants