-
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
Precision lost when decode long field in browser #758
Comments
Is In case of doubt, try the following before decoding anything: var Long = ...;
protobuf.util.Long = Long;
protobuf.configure(); |
@dcodeIO in NodeJS, |
Then long.js isn't present / recognized in your browser build and unsafe numbers are used (see long.js for more information on why precision loss is happening). Try assigning Long explicitly as shown above prior to decoding. More information on why this is happening is available here. |
Okay. |
That's strange. Basically, long.js is loaded automatically when a global |
@dcodeIO var $protobuf = require("protobufjs/minimal");
//add this
var Long = require('long');
$protobuf.util.Long = Long;
$protobuf.configure(); |
You can do this in any other file as well, it's just important to do it once in your project. |
protobuf.js version:
6.7.3
Reproduction code
test.proto
generate scripts:
index.js
webpack.config.js
Result
Run in node: (works well)
Run in browser: (wrong result)
Notice "9899" at tail was lost!
The text was updated successfully, but these errors were encountered: