Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/make-middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ function makeMiddleware (setup) {
abortWithCode('LIMIT_FILE_SIZE', fieldname)
})

var closed = false
req.on('close', function () {
closed = true
})

storage._handleFile(req, file, function (err, info) {
if (aborting) {
appender.removePlaceholder(placeholder)
Expand All @@ -157,6 +162,9 @@ function makeMiddleware (setup) {
appender.replacePlaceholder(placeholder, fileInfo)
uploadedFiles.push(fileInfo)
pendingWrites.decrement()
if (closed) {
return abortWithCode('REQUEST_CLOSED')
}
indicateDone()
})
})
Expand Down
3 changes: 3 additions & 0 deletions storage/disk.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ DiskStorage.prototype._handleFile = function _handleFile (req, file, cb) {
size: outStream.bytesWritten
})
})
req.on('close', function () {
outStream.end()
})
})
})
}
Expand Down