mscdex / dicer

A very fast streaming multipart parser for node.js
MIT License
186 stars 36 forks source link

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

Closed aaabhilash97 closed 6 years ago

aaabhilash97 commented 6 years ago

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 commented 6 years ago

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

aaabhilash97 commented 6 years ago

We are getting this error with busboy. https://github.com/mscdex/dicer/blob/3f75d507b7ad1a395f04028c724ee3ad99b78bb4/lib/Dicer.js#L65

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 commented 6 years ago

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

aaabhilash97 commented 6 years ago

Thanks, @mscdex . Will try this.

jonas060831 commented 6 years ago

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 commented 6 years ago

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

file.on('error', ()=>{})
saeidalidadi commented 3 years ago

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 commented 2 years ago

Any solution on this one?