Request pending if file limit exceed
See original GitHub issueI use multer with single file variant.
var multer = require('multer');
var avatarMulter = multer({
dest: './uploads/avatar',
limits: {
fieldNameSize: 100,
fileSize: 1048576,
files: 1,
fields: 1
}
});
app.post('/api/photo', avatarMulter.single('file'), auth.requiresLogin, usersCustom.processAvatarImage);
Log:
Error: File too large
at makeError (C:\Users\Viktor\Develop\OnlineKonzultace\sources\onlinekonzultace\node_modules\multer\lib\make-error.js:12:13)
at abortWithCode (C:\Users\Viktor\Develop\OnlineKonzultace\sources\onlinekonzultace\node_modules\multer\lib\make-middleware.js:64:22)
at FileStream.<anonymous> (C:\Users\Viktor\Develop\OnlineKonzultace\sources\onlinekonzultace\node_modules\multer\lib\make-middleware.js:116:11)
at FileStream.emit (events.js:104:17)
at PartStream.onData (C:\Users\Viktor\Develop\OnlineKonzultace\sources\onlinekonzultace\node_modules\multer\node_modules\busboy\lib\types\multipart.js:212:18)
at PartStream.emit (events.js:107:17)
at readableAddChunk (_stream_readable.js:163:16)
at PartStream.Readable.push (_stream_readable.js:126:10)
at Dicer._oninfo (C:\Users\Viktor\Develop\OnlineKonzultace\sources\onlinekonzultace\node_modules\multer\node_modules\busboy\node_modules\dicer\lib\Dicer.js:192:36)
at SBMH.<anonymous> (C:\Users\Viktor\Develop\OnlineKonzultace\sources\onlinekonzultace\node_modules\multer\node_modules\busboy\node_modules\dicer\lib\Dicer.js:127:10)
at SBMH.emit (events.js:118:17)
at SBMH._sbmh_feed (C:\Users\Viktor\Develop\OnlineKonzultace\sources\onlinekonzultace\node_modules\multer\node_modules\busboy\node_modules\dicer\node_modules\streamsearch\lib\sbmh.js:188:10)
at SBMH.push (C:\Users\Viktor\Develop\OnlineKonzultace\sources\onlinekonzultace\node_modules\multer\node_modules\busboy\node_modules\dicer\node_modules\streamsearch\lib\sbmh.js:56:14)
at Dicer._write (C:\Users\Viktor\Develop\OnlineKonzultace\sources\onlinekonzultace\node_modules\multer\node_modules\busboy\node_modules\dicer\lib\Dicer.js:109:17)
at doWrite (_stream_writable.js:301:12)
at writeOrBuffer (_stream_writable.js:288:5)
at Dicer.Writable.write (_stream_writable.js:217:11)
at Multipart.write (C:\Users\Viktor\Develop\OnlineKonzultace\sources\onlinekonzultace\node_modules\multer\node_modules\busboy\lib\types\multipart.js:282:24)
at Busboy._write (C:\Users\Viktor\Develop\OnlineKonzultace\sources\onlinekonzultace\node_modules\multer\node_modules\busboy\lib\main.js:72:16)
at doWrite (_stream_writable.js:301:12)
at writeOrBuffer (_stream_writable.js:288:5)
at Busboy.Writable.write (_stream_writable.js:217:11)
POST /api/photo 500 - - 74.112 ms
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.
multerInstance(req, res, function (err) {
if (err) {
console.log(err);
return res.status(500).json({error: 'error'});
}
console.log('OK');
res.json({});
})
Issue Analytics
- State:
- Created 8 years ago
- Comments:19 (7 by maintainers)
Top Results From Across the Web
File Size Limit Exceeded Error Under Linux and Solution
I do have enough disk space to copy this file. I am getting an error “file size limit exceeded” under Linux. How do...
Read more >e-Request - Outside Normal Processing Time
If you are a DACA renewal applicant please contact USCIS at (1-800) 375-5283 to inquire on a case pending longer than 105 days....
Read more >Rate Limits - Let's Encrypt
Exceeding the Pending Authorizations limit is reported with the error message too many currently pending authorizations .
Read more >Understanding Kubernetes Limits and Requests - Sysdig
Kubernetes defines Limits as the maximum amount of a resource to be used by a container. This means that the container can never...
Read more >I'm experiencing a long response time - Postman
If the response size of your request exceeds 100MB, you can use the following workaround: try using the Send and Download option when...
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 FreeTop 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
Top GitHub Comments
Here is complete code:
There is one work around which I have used in my current project
File: make-middleware.js change “function done(err)” at end of this function
Replace Line 52:
onFinished(req, function () { next(err) })
With: Line 52:
onFinished(req, function () { if( typeof err != "undefined" && err.code == 'LIMIT_FILE_SIZE') { req.fileSizeError = 1; next() } else next(err) })
And in app file you can change the code to