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

Comments

Projects
None yet
4 participants
@yoni-tock

yoni-tock commented Feb 27, 2017

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
@r-tock

This comment has been minimized.

Contributor

r-tock commented Feb 27, 2017

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

@dcodeIO dcodeIO closed this in 88eb7a6 Feb 28, 2017

@dcodeIO

This comment has been minimized.

Owner

dcodeIO commented Feb 28, 2017

Please let me know if this solves your issue!

@dcodeIO dcodeIO added the bug label Feb 28, 2017

@r-tock

This comment has been minimized.

Contributor

r-tock commented Feb 28, 2017

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

@yoni-tock

This comment has been minimized.

yoni-tock commented Feb 28, 2017

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

@dcodeIO

This comment has been minimized.

Owner

dcodeIO commented Feb 28, 2017

Now on npm!

@raojs

This comment has been minimized.

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