Skip to content
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

node:zlib brotli compression stream truncates data #22259

Closed
0f-0b opened this issue Feb 4, 2024 · 1 comment · Fixed by #22322 or #22856
Closed

node:zlib brotli compression stream truncates data #22259

0f-0b opened this issue Feb 4, 2024 · 1 comment · Fixed by #22322 or #22856
Assignees
Labels
bug Something isn't working correctly node API Related to various "node:*" modules APIs node compat

Comments

@0f-0b
Copy link
Contributor

0f-0b commented Feb 4, 2024

import { Readable } from "node:stream";
import { buffer } from "node:stream/consumers";
import { createBrotliCompress, createBrotliDecompress } from "node:zlib";

const input = new Uint8Array(1000000);
for (let i = 0; i < input.length; i++) {
  input[i] = Math.random() * 256;
}
const output = await buffer(
  Readable.from([input])
    .pipe(createBrotliCompress())
    .pipe(createBrotliDecompress()),
);
console.log(output.length);
$ deno run a.mjs
1020
$ node a.mjs
1000000

Version: Deno 1.40.3+a284f50

@0f-0b
Copy link
Contributor Author

0f-0b commented Feb 8, 2024

This still happens if the data is not randomly generated.

import { Readable } from "node:stream";
import { buffer } from "node:stream/consumers";
import { createBrotliCompress, createBrotliDecompress } from "node:zlib";

const input = new Uint8Array(1000000);
const output = await buffer(
  Readable.from([input])
    .pipe(createBrotliCompress())
    .pipe(createBrotliDecompress()),
);
console.log(output.length); // 14
$ deno --version
deno 1.40.3+431bf31 (canary, aarch64-apple-darwin)
v8 12.1.285.6
typescript 5.3.3

@littledivy littledivy reopened this Feb 8, 2024
@bartlomieju bartlomieju added the node API Related to various "node:*" modules APIs label Mar 4, 2024
@bartlomieju bartlomieju assigned littledivy and unassigned littledivy Mar 5, 2024
littledivy added a commit to littledivy/deno that referenced this issue Mar 12, 2024
Fixes denoland#22259

The decompressed input size was not restored because of improper flushing of the CBrotliDecompressStream state.
littledivy added a commit that referenced this issue Mar 12, 2024
Fixes #22259

The decompressed input size was not restored because of improper
flushing of the CBrotliDecompressStream state.
nathanwhit pushed a commit that referenced this issue Mar 14, 2024
Fixes #22259

The decompressed input size was not restored because of improper
flushing of the CBrotliDecompressStream state.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly node API Related to various "node:*" modules APIs node compat
Projects
None yet
3 participants