bun icon indicating copy to clipboard operation
bun copied to clipboard

`CompressionStream` & `DecompressionStream` types don't support brotli & zstd

Open kylekz opened this issue 2 weeks ago • 7 comments

What version of Bun is running?

1.3.3+274e01c73

What platform is your computer?

Linux 6.6.87.2-microsoft-standard-WSL2 x86_64 x86_64

What steps can reproduce the bug?

simple example from the 1.3.3 blog post detailing CompressionStream implementation:

async function main() {
  const response = await fetch("https://example.com");
  const zstd = response.body!.pipeThrough(new CompressionStream("zstd"));
}

What is the expected behavior?

types for CompressionStream and DecompressionStream should have brotli and zstd added

What do you see instead?

type error: Argument of type '"zstd"' is not assignable to parameter of type 'CompressionFormat'.

Additional information

No response

kylekz avatar Dec 06 '25 03:12 kylekz

Yeah they aren't officially standard ones. I think it's still possible for bun to add extra "overloads" though.

RiskyMH avatar Dec 06 '25 06:12 RiskyMH

yep the functionality works fine since it can just be casted to CompressionFormat, it's just a bit strange to require casting or tsignore for an officially supported feature

kylekz avatar Dec 06 '25 06:12 kylekz

  • I made new the function from CompressionStream / DecompressionStream to easy using
Image
  • And this is native CompressionStream / DecompressionStream
Image
  • I did not get any errors such as type error: Argument of type '"zstd"' is not assignable to parameter of type 'CompressionFormat'. Maybe it just happens Linux 6.6.87.2-microsoft-standard-WSL2 x86_64 x86_64 ?

truongan07 avatar Dec 06 '25 07:12 truongan07

yep the functionality works fine since it can just be casted to CompressionFormat, it's just a bit strange to require casting or tsignore for an officially supported feature

Yoo nice, feel free to make a pr and @alii should review and merge!

RiskyMH avatar Dec 06 '25 09:12 RiskyMH

https://github.com/oven-sh/bun/pull/25374

admittedly needed claude to guide me but these changes when made in my own project's node_modules seems to work, feel free to just close if it's just slop

kylekz avatar Dec 06 '25 14:12 kylekz

Thank you for reporting and opening a pull request! I left a couple notes on the PR :-)

alii avatar Dec 06 '25 19:12 alii

Hi @alii , please support ArrayBuffer (output) for CompressionStream / DecompressionStream

truongan07 avatar Dec 07 '25 09:12 truongan07