Skip to content
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

Error: Part terminated early due to unexpected end of multipart data #14

Closed
aaabhilash97 opened this issue Jan 18, 2018 · 8 comments
Closed

Comments

@aaabhilash97
Copy link

Hi,
Getting this error often, But don't know what is the exact scenario.
Any idea how to catch this error?

Error: Part terminated early due to unexpected end of multipart data
    at /srv/storage-server/node_modules/dicer/lib/Dicer.js:65:36
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9)
@mscdex
Copy link
Owner

mscdex commented Jan 18, 2018

Listen for the 'error' event. It means you have a part that is not properly terminated.

@aaabhilash97
Copy link
Author

aaabhilash97 commented Jan 18, 2018

We are getting this error with busboy.

self._part.emit('error', new Error(type + ' terminated early due to unexpected end of multipart data'));

How can I listen to this._part's events from busboy?

Attaching my code snippet also

    var parser = new busboy({
        headers: req.headers
    });
    parser.on('error', function(error) {
        logger.error("Busboy error catching......>>>>>>>>>>>>>>", error);
    });
    parser.on('file', function(fieldname, file) {
    }
    parser.on('field', function(fieldname, file) {
    }

@mscdex
Copy link
Owner

mscdex commented Jan 18, 2018

It's most likely happening while parsing a file. Did you try adding an 'error' handler for file in the 'file' event handler?

@aaabhilash97
Copy link
Author

Thanks, @mscdex . Will try this.

@jonas060831
Copy link

jonas060831 commented Jun 5, 2018

Hello im also getting this error cant seem to catch it
after deploying it to serverless and trying to run it locally the first time i tried the route it will fail but the subsequent request will work i really cannot find the error what causes such behaviour

Serverless: Offline listening on http://localhost:3000

Serverless: ANY /upload-image (λ: app)
Serverless: The first request might take a few extra seconds
Listening on port 3000!
Serverless: [500] {"isBase64Encoded":false,"statusCode":500,"headers":{"x-powered-by":"Express","access-control-allow-origin":"*","content-security-policy":"default-src 'self'","x-content-type-options":"nosniff","content-type":"text/html; charset=utf-8","content-length":457},"body":"<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<title>Error</title>\n</head>\n<body>\n<pre>Error: Unexpected end of multipart data<br> &nbsp; &nbsp;at /path/ImageUploaderLambdaFunc/node_modules/dicer/lib/Dicer.js:62:28<br> &nbsp; &nbsp;at _combinedTickCallback (internal/process/next_tick.js:131:7)<br> &nbsp; &nbsp;at process._tickDomainCallback (internal/process/next_tick.js:218:9)</pre>\n</body>\n</html>\n"}


Error: Unexpected end of multipart data
    at /path/ImageUploaderLambdaFunc/node_modules/dicer/lib/Dicer.js:62:28
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9)
Debug: internal, implementation, error 
    TypeError: req.socket.destroy is not a function
    at Immediate.<anonymous> (/path/ImageUploaderLambdaFunc/node_modules/finalhandler/index.js:128:18)
    at Immediate._onImmediate (/path/ImageUploaderLambdaFunc/node_modules/express/lib/router/index.js:635:15)
    at runCallback (timers.js:791:20)
    at tryOnImmediate (timers.js:751:5)
    at processImmediate [as _immediateCallback] (timers.js:722:5)
Error: Part terminated early due to unexpected end of multipart data
    at /path/ImageUploaderLambdaFunc/node_modules/dicer/lib/Dicer.js:65:36
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9)

@aaabhilash97
Copy link
Author

aaabhilash97 commented Jun 8, 2018

@jonas060831
We can catch the error by attaching an error event handler to the file object.

file.on('error', ()=>{})

@saeidalidadi
Copy link

I could handle this error for the first request, But for the second one the response is blocked and I could not find the reason.

@iamabdulhaseeb
Copy link

Any solution on this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants