Skip to content

Commit 5a4721f

Browse files
committed
Fixes #256
1 parent 1216f4f commit 5a4721f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/processMultipart.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ module.exports = (options, req, res, next) => {
5757
} = options.useTempFiles
5858
? tempFileHandler(options, field, filename) // Upload into temporary file.
5959
: memHandler(options, field, filename); // Upload into RAM.
60+
61+
const writePromise = getWritePromise();
62+
if (options.useTempFiles) {
63+
writePromise.catch(err => {
64+
uploadTimer.clear();
65+
cleanup();
66+
next(err);
67+
});
68+
}
69+
6070
// Define upload timer.
6171
const uploadTimer = new UploadTimer(options.uploadTimeout, () => {
6272
file.removeAllListeners('data');
@@ -114,7 +124,7 @@ module.exports = (options, req, res, next) => {
114124
if (!req[waitFlushProperty]) {
115125
req[waitFlushProperty] = [];
116126
}
117-
req[waitFlushProperty].push(getWritePromise());
127+
req[waitFlushProperty].push(writePromise);
118128
});
119129

120130
file.on('error', (err) => {

0 commit comments

Comments
 (0)