-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multer & Express.js File Upload request hanged (never ending pending) #1218
Comments
@agussetyar I guess you need to add the header |
Already tried this approach, but also not working in my cases. |
fileFilter( req, bile, cb ) { cb( new Error( 'error' ), false ) } Processing works fine on the web, but when an application uses network communication, a timeout occurs in the Pending state. We have confirmed that the busboy.on('close') event does not fall into the Pending state. I corrected the code as below so that the storage._handleFile handled the error. /lib/make-middleware.js: 116 if (err) {
appender.removePlaceholder(placeholder)
return abortWithError(err)
}
if (!includeFile) {
appender.removePlaceholder(placeholder)
return fileStream.resume()
}
var aborting = false
pendingWrites.increment() var aborting = false
pendingWrites.increment()
if (err||!includeFile) {
aborting = true
abortWithError(err)
} |
…ile upload in native app.
I have encountered this issue as well. It can be replicated even when I use Postman. |
I think this issue is due to the empty array of uploadedFiles, which causes the remove callback to not be triggered. |
@Hongdaesik I'm curious about why this bug block exactly the first request after the filter file error. |
original code: after applying the fix: |
for those who are waiting for merge, you can apply this fix in application code:
|
@pwliuab I'll check it out in more detail and make further corrections when I have time! thx! |
@Hongdaesik thanks, I will investigate the detail as well, seems interesting. |
I'm working with very simple file upload feature using Express.js & Multer.
This is my multer middleware code:
This is my error handler middleware:
When I hit this endpoint from Frontend (React.js) using Axios and FormData. I got never ending 'pending' request and I dont know why this is happen with this simple code. The expected results is custom JSON response should be returned.
After a minutes searching, I found that if I remove the 'FileValidationError' from error handler logic or using this code:
The request is not pending and it returned response the Error() instance.
But, this behavior only happens in the Frontend side. I tested with Postman and the request looks fine.
Can someone tell me If I do something wrong in this situation?
The text was updated successfully, but these errors were encountered: