Version
latest main branch
Platform
Subsystem
zlib
What steps will reproduce the bug?
const assert = require('node:assert/strict');
const zlib = require('node:zlib');
const input = Buffer.alloc(42);
assert.throws(
() => zlib.zstdCompressSync(input, {
pledgedSrcSize: 1,
}),
{
code: 'ZSTD_error_srcSize_wrong',
},
);
How often does it reproduce? Is there a required condition?
Every Time
What is the expected behavior? Why is that the expected behavior?
zstdCompressSync() should throw an error with:
{
code: 'ZSTD_error_srcSize_wrong',
errno: zlib.constants.ZSTD_error_srcSize_wrong,
}
What do you see instead?
Compression succeeds, causing assert.throws() to fail with
Additional information
The synchronous convenience API processes the input using the default final operation:
ZSTD_e_end
Therefore, its first compression call is effectively:
ZSTD_compressStream2(cctx, output, input, ZSTD_e_end);
Zstd has special behavior for this case. When the first call for a frame uses ZSTD_e_end, it replaces a previously configured pledged source size with the current input size.
Version
latest main branch
Platform
Subsystem
zlib
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Every Time
What is the expected behavior? Why is that the expected behavior?
zstdCompressSync() should throw an error with:
What do you see instead?
Compression succeeds, causing assert.throws() to fail with
Additional information
The synchronous convenience API processes the input using the default final operation:
ZSTD_e_endTherefore, its first compression call is effectively:
ZSTD_compressStream2(cctx, output, input, ZSTD_e_end);Zstd has special behavior for this case. When the first call for a frame uses ZSTD_e_end, it replaces a previously configured pledged source size with the current input size.