Open ludovicm67 opened 3 months ago
Apparently globalThis.ReadableStream
is not supported yet in this. I think it should be easy enough to add it if we switch from pump
to require('stream').pipeline
in this module. pipeline
should handle these out of the box.
(As a workaround, you can call require('node:stream').Readable.fromWeb(res.body)
)
A PR with a fix would be highly welcomed!
@mcollina Thank you a lot for the workaround ; this is working well 👍
Regarding replacing pump
with require('stream').pipeline
was not working unfortunately ; the same issue is still present.
I attempted to solve this in #312 but in the end I think solving this would require a bigger re-architecture to more modern standards as also described by @mcollina here https://github.com/fastify/fastify-compress/issues/297#issuecomment-2119902305 but there is a test case I added on that branch if anyone else wants to pick this up
Prerequisites
Fastify version
4.28.1
Plugin version
7.0.3
Node.js version
20.15.1
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
14.6.1
Description
On an async function, I return a stream for the body. If the user doesn't request compression, then it works as expected. But if he asks for compression, then he gets a 500 and the following error:
Minimal reproducible example
Configure a basic project and install required modules:
index.js:
Example of requests:
All requests are working as expected, except the last one.
Here is the output I'm getting:
Link to code that reproduces the bug
No response
Expected Behavior
I expect that in the reproduction example, the
curl -v --compressed http://localhost:3000/broken
command is returning the expected output to the user, and not an error.Maybe it's a missing feature, and implementing chunk-encoding for streams would solve this?