-
Type: Bug
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
Reproducible Environment:
- Apple M1 Mac ie Darwin arm 64
- Linux x64
Generated zstd function during build does not include level parameter in node_modules/@mongodb-js/zstd/index.js:
// NB: If you update any type signatures to diverge from bindings itself, make// sure to update how index.d.ts is generated (napi build --dts ...) const { compress: _compress, decompress: _decompress } =require('./bindings'); // Error objects created via napi don't have JS stacks; wrap them so .stack is present// https://github.com/nodejs/node/issues/25318#issuecomment-451068073 exports.compress = async function compress(data) { try { return await _compress(data); } catch (e) { throw new Error(`zstd: ${e.message}`); }};exports.decompress = async function decompress(data) { try { return await _decompress(data); } catch (e) { throw new Error(`zstd: ${e.message}`); }};
I had to create a patch to add in level and get the compression level parameter working:
diff --git a/node_modules/@mongodb-js/zstd/index.js b/node_modules/@mongodb-js/zstd/index.js index 422ca93..cd119a0 100644 --- a/node_modules/@mongodb-js/zstd/index.js +++ b/node_modules/@mongodb-js/zstd/index.js @@ -6,9 +6,9 @@ const { compress: _compress, decompress: _decompress } = require('./bindings'); // Error objects created via napi don't have JS stacks; wrap them so .stack is present // https://github.com/nodejs/node/issues/25318#issuecomment-451068073 -exports.compress = async function compress(data) { +exports.compress = async function compress(data, level) { try { - return await _compress(data); + return await _compress(data, level); } catch (e) { throw new Error(`zstd: ${e.message}`); }