Skip to content

Commit b3d69ae

Browse files
committed
fix: handle two busboy error events
1 parent 8ec534f commit b3d69ae

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/make-middleware.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function makeMiddleware (setup) {
4141
if (isDone) return
4242
isDone = true
4343
req.unpipe(busboy)
44-
process.nextTick(() => {
44+
setImmediate(() => {
4545
busboy.removeAllListeners()
4646
})
4747
next(err)

test/express-integration.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,19 @@ describe('Express Integration', function () {
115115
})
116116

117117
app.use(function (err, req, res, next) {
118-
assert.strictEqual(err.message, 'Unexpected end of form')
118+
assert.strictEqual(err.message, 'Malformed part header')
119119
res.status(200).end('Correct error')
120120
})
121121

122122
var boundary = 'AaB03x'
123+
// this payload causes two errors to be emitted by busboy: `Malformed part header` and `Unexpected end of form`
123124
var body = [
124125
'--' + boundary,
125126
'Content-Disposition: form-data; name="file"; filename="test.txt"',
126127
'Content-Type: text/plain',
127128
'',
128-
'test without end boundary'
129+
'--' + boundary + '--',
130+
''
129131
].join('\r\n')
130132
var options = {
131133
hostname: 'localhost',

0 commit comments

Comments
 (0)