Comments (5)
I'm not sure yet. Can you list what version of this module you are using as well as what version of Node.js?
from compression.
well you're using express wrong in the first place. you're executing next()
and res.send()
at the same time.
from compression.
Oh, I didn't even notice that. Yes, that would 100% cause the error you are getting. Remove the return next()
.
from compression.
Ok, thank for explanations. I realize that this more an express-related question but what if i want to have some kind of login/error-handling?
var app = require('express')();
var compression = require('compression');
app.use(compression({ threshold: 512 }));
// controller
app.use(function (req, res) {
res.status(201);
res.send(Array(6000).join("."));
//return next();
});
// logging middleware
app.use(function (req, res, next) {
console.log(res.statusCode);
return next(new Error('log_error'));
});
// error handling
app.use(function (err, req, res, next) {
console.error('Error>', err.message);
return next();
});
app.listen(9000);
from compression.
I'm not sure what you're asking, but as soon as you call res.send()
, you're done; if you remove that res.send()
it's more like that you want. Please feel free to ask for help on learning from the express community (http://expressjs.com/resources/community.html) on Google Groups (https://groups.google.com/group/express-js) or IRC (#express
n freenode.net).
from compression.
Related Issues (20)
- Setting Vary header although caching is disabled HOT 1
- "drain" event listener leak when using res.once("drain"); can't use res.removeListener("drain") HOT 3
- compresssion doesn't work ,the vue.txt is 2m HOT 2
- Content-Type: application/json; charset=utf-8 No effect HOT 2
- Question: Why this middleware HOT 2
- Corrupted compressed .js-files for Mac OS / Safari -clients HOT 11
- Is compression working when node server is running on a container? HOT 2
- middleware fails when the request has more than 1 values for accept-encoding header HOT 2
- Is compression result cached? HOT 1
- change Transfer-encoding HOT 1
- Why does the data size increase after compression HOT 1
- Force size to be a minimum... HOT 2
- Chunked encoding is broken after using this middleware HOT 1
- Using a current debug version HOT 1
- Deflate backwards HOT 7
- Compression instrumentation (before/after compression hooks) HOT 2
- Angular Not Compressing? HOT 2
- compression not working json payload HOT 6
- Crash when compressing characters like ū HOT 1
- Express returns a non-compliant HTTP/206 response when gzip is enabled HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compression.