-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Request pending if file limit exceed #168
Comments
I made a most simply example as possible var express = require('express')
var multer = require('multer')
var logger = require('morgan');
var upload = multer(
{
dest: 'uploads/',
limits: {
fields: 1,
files: 1,
fileSize: 512000
}
})
var app = express();
app.use(express.static('public'));
app.use(logger());
app.post('/avatar', upload.single('file'), function (req, res, next) {
res.end('finished');
})
var server = app.listen(3000, function () {
var host = server.address().address;
var port = server.address().port;
console.log('Example app listening at http://%s:%s', host, port);
}); Pending problem start when i add error handler function to express: app.use(function(err, req, res, next) {
console.log('ERROR');
res.status(500);
res.end('');
console.error(err.stack);
}); There is a HTML index.html file: <html>
<body>
<form action="/avatar" method="POST" enctype="multipart/form-data">
<input type="file" name="file" />
<input type="submit" value="Send" />
</form>
</body>
</html> With file which exceed defined limit, POST request pending and doesn't end. Without error handler function, request ends, with exception stack as response body. |
where did you add the error handling function? (it matters) |
Here is complete code: var express = require('express')
var multer = require('multer')
var logger = require('morgan');
var upload = multer(
{
dest: 'uploads/',
limits: {
fields: 1,
files: 1,
fileSize: 512000
}
})
var app = express();
app.use(express.static('public'));
app.use(logger());
app.post('/avatar', upload.single('file'), function (req, res, next) {
res.end('finished');
})
app.use(function(err, req, res, next) {
console.log('ERROR');
res.status(500);
res.end('');
console.error(err.stack);
});
var server = app.listen(3000, function () {
var host = server.address().address;
var port = server.address().port;
console.log('Example app listening at http://%s:%s', host, port);
}); |
Hi, Exact same problem since upgrading to The problem occurs when uploading a file which has a size > The error is delegated to express but the response seems to never end. Here is a simple example: var express = require('express');
var multer = require('multer');
var router = express.Router();
var multerConf = multer({
dest: './uploads/',
limits: {
fileSize: 5 * 1000000
}
});
router.post('/', multerConf.single('file'), function (req, res) {
res.status(200).send({file: req.file});
});
router.use(function (err, req, res, next) {
res.status(413).send('File too large');
})
module.exports = router; I am doing something wrong? Also, what's the best way to delete a partially uploaded file (previously it was done via |
Partially uploaded files will now be removed automatically 🎆 Otherwise I don't think you are doing anything wrong, this seems to be a confirmed bug and I think that I have traced it to somewhere between multer and busboy. For some reason the incoming pipe won't start again after I |
I have similar issue with the following setup:
I see this issue constantly: it doesn't matter if this is the very first upload that exceeds the limit or it comes after some successful uploads (when limit is met). |
Should be fixed by dfa2095, please reopen if issue persists. Finally 🎆 🍹 |
I confirm my issue above is fixed. Great work! |
Thank you! |
Turns out that this issue was probably a bug in Node.js, and I just managed to slightly work around it 😭 |
There is one work around which I have used in my current project File: make-middleware.js Replace With: And in app file you can change the code to
|
I am also getting the same error. used @sumedhm-iprogrammer hack currently to work. But hoping this will get fixed soon |
Which version of Node.js are you using? |
Hey @LinusU |
If you are getting error Error: File too large File: make-middleware.js Replace With: And in app file you can change the code to app.post('/upload', upload.single('upload'), function (req, res, next) { |
I found most appropriate way to fix above issue var storage = multer.diskStorage({
api.post('/users/profile' ,function ( req, res, next) { Their is no need to chnage middleare [ multer ] file Replace With: |
I can confirm the above works, it worked for me, it will work for other broken limits encountered by multer as well |
Is there any possibility to make it work without having to modify the lib? |
I use multer with single file variant.
Log:
But express still processing request (rrequest is still pending from browser). Also invalid file is not deleted from /upload/avatar directory.
I try use checking err directly (below), but problem is same. My processing avatar function is never run after mutler CB. I also try remove everything except mutler callback and problem is still in.
The text was updated successfully, but these errors were encountered: