expressjs / expressjs/multer

busboy finish event called after abortWithError

Open
#1,121 0 comments 0 reactions 0 assignees View on GitHub
investigate
Dominant language
JavaScript
Stars
12.1k
Forks
1.1k
Avg merge
8d 2h
Merged PRs (30d)
21

Description

Sometimes when our first request chunk is 16334, it seems that after giving error inside the `fileFilter` callback and `abortWithError` was called, in the end of the request chunk, the busboy finish event is emitted and this caused error from the DIcer finish event.

```node:events:504
throw er; // Unhandled 'error' event
^

Error: Unexpected end of multipart data
at /app/node_modules/dicer/lib/Dicer.js:62:28
at processTicksAndRejections (node:internal/process/task_queues:78:11)
Emitted 'error' event on Busboy instance at:
at Busboy.emit (/app/node_modules/busboy/lib/main.js:38:33)
at Dicer. (/app/node_modules/busboy/lib/types/multipart.js:281:9)
at Dicer.emit (node:events:526:28)
at Dicer.emit (node:domain:475:12)
at Dicer.emit (/app/node_modules/dicer/lib/Dicer.js:80:35)
at /app/node_modules/dicer/lib/Dicer.js:62:14
at processTicksAndRejections (node:internal/process/task_queues:78:11)
```

But then, when our first chunk is 65486, the busboy finish event is not emitted after the `abortWithError`.

our setting:
readableHighWaterMark 16384
writableHighWaterMark 16384
multer: 1.4.4
node: 16.14.2

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the reported multer 1.4.4 and Node 16.14.2 settings using request chunks of 16334 and 65486 bytes. Trace the abort path through busboy/lib/main.js, busboy/lib/types/multipart.js, and dicer/lib/Dicer.js, focusing on fileFilter and abortWithError. Done means aborting does not produce a later unhandled finish or error event.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.