reply.compress is not working as expected
See original GitHub issuePrerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the bug has not already been reported
Fastify version
4.9.2
Plugin version
6.1.1
Node.js version
18.10.0
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
Alpine Linux 3.16 with node 18
Description
as documented, I registered the plugin with code:
fastify.register(require('@fastify/compress'),{global: false })
then tried to use reply.compress()
I have this error (and crash):
/home/node/code/models/stream-result.js:46
reply.type('application/json').compress(piped);
^
TypeError: reply.type(...).compress is not a function
piped is a stream, and replacing with compress
with send
works
Steps to Reproduce
not sure if it is needed to pass reply object to an external function to reproduce the error
Expected Behavior
It should accept a stream and stream it.
Issue Analytics
- State:
- Created a year ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Response compression in asp.net core 2.2 not working
UseResponseCompression() to the top of the method. I validated it and found working fine as expected. public void Configure(IApplicationBuilder ...
Read more >Premature close · Issue #215 · fastify/fastify-compress - GitHub
This appears to happen when request is aborted while still serving the file. Expected Behavior. Should produce a warning, but not an uncaught ......
Read more >5.0 zstd compression level is not working as expected
Hi @Aayushi_Mangal. Compression performance depends very much on the documents. If the document contains a random string pattern, ...
Read more >Troubleshooting IIS Compression issues in IIS6/IIS7.x
Enable Compression in IIS6/IIS7: From the IIS Manager, right-click on the Web Sites node, Properties and click on Services. Screenshot of ...
Read more >ASP.NET Response Compression - wolfSYS.net
Compression is a simple and effective way to save bandwidth and speed up your site. Here we'll cover both classic ASP.NET MVC and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I always recommend people to put all the
routes
inside a plugin. So, they will not face similar issue. I do not recommend to placefastify.get
or similar in the same level offastify.register
.For example,
should refactor into
In this case, wrapper of
async
start is not needed.It is supported in
commonjs
. And I have no idea why it didn’t works for you without a minimal repo.My guess is about there are something wrong about your setup. For example, the routes and
@fastify/compress
are inside separate encapsulation context.Another though is all the
plugin
is registered inside the same file. And you did notawait
that file in the most upper layer.