-
-
Notifications
You must be signed in to change notification settings - Fork 74
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
Error decoding object with large buffer #43
Comments
Issue is not present in forked project at https://www.npmjs.com/package/borc |
My guess is that there is an anomaly in the buffering code. looking into it. |
@BryceCicada, this is the point at which we blow past the highWaterMark in the output NoFilter. If you stream the output, rather than using the sync mode, it works correctly:
Still working on a fix. |
@linuxwolf thought he might be able to look at this. Note: I think the actual issue is roughly at https://github.com/hildjj/nofilter/blob/509192e5ccf71208b6cef8734933ddc5a1d8ffce/src/index.coffee#L252, where I don't check the return value of |
In this case, I don't think checking the result of A quick fix is to set the |
Actually, nevermind all that (-: It is a problem with the The fix is probably to work around the |
I'm seeing the same issue. It seems that the problem occurs only if the large item is both encoded and decoded by node-cbor. It does not occur if either encoding or decoding is performed with another library. const cbor = require("cbor");
const CBOR = require("cbor-sync");
const isArray = require("util").isArray;
const length = 5000; // >=3500 triggers the bug
const input = [];
for (let i = 0; i < length; ++i) {
input.push(i.toString());
}
function testEncodeDecode(title, encode, decode) {
const wire = encode(input);
let result;
try {
result = decode(wire);
}
catch (ex) {
console.error(title, ex);
return;
}
if (!isArray(result)) {
console.error(title, "bad-type");
return;
}
if (result.length != input.length) {
console.error(title, "bad-length", result.length);
return;
}
console.log(title, "OK");
}
testEncodeDecode("cbor => cbor", cbor.encode, cbor.decodeFirstSync);
testEncodeDecode("cbor => cbor-sync", cbor.encode, CBOR.decode);
testEncodeDecode("cbor-sync => cbor", CBOR.encode, cbor.decodeFirstSync);
testEncodeDecode("cbor-sync => cbor-sync", CBOR.encode, CBOR.decode); The output is:
|
I was running into [this bug](hildjj/node-cbor#43)
I was running into [this bug](hildjj/node-cbor#43)
I got into the same problem, solved with https://github.com/dignifiedquire/borc |
I got the same problem, and borc work will indeed. |
Same problem here, fixed with borc |
I got the same problem, and borc work will indeed. |
It's important to note that |
The following snippet fails with error at decode:
The size of buffer for which the error occurs depends on the name of the object properties a and b. That is, if the names are longer then shorter buffers produce the error.
With property names a and b, the error does not occur if I reduce the size of buffer to 16376 bytes, like:
The error does not occur if I switch the order of a and b in object, like:
Reproduced with 2.0.0 and 3.0.0
The text was updated successfully, but these errors were encountered: