'Node.js Error: Request aborted in File upload formidable

I am using formidable module https://github.com/felixge/node-formidable to upload images. I created a separate new project & file upload works perfectly.

But when i integrate it in my existing project. I get following error :-

Error: Request aborted
at IncomingMessage.onReqAborted (D:\ProjectName\node_modules\express\node_modules\connect\node_modules\multiparty\index.js:131:17)
at IncomingMessage.EventEmitter.emit (events.js:92:17)
at abortIncoming (http.js:1911:11)
at Socket.serverSocketCloseListener (http.js:1923:5)
at Socket.EventEmitter.emit (events.js:117:20)
at TCP.close (net.js:466:12)

Any idea How to Solve this?

I tried ON event :-

form.on('progress', function (bytesReceived, bytesExpected) {
        console.log('PROGRESS');
        console.log(bytesReceived);
        console.log(bytesExpected);
    });

It gives me result for above code as :-

PROGRESS
0
488

It doesn't go ahead of this.



Solution 1:[1]

try to delete this in your app.js:

app.use(express.bodyParser());

Solution 2:[2]

It might be little late for OP, but for others: just set/increase the nodejs timeout like so:

server.timeout = 1000 * 60 * 10; // 10 mins

formidable uses this setting after which it throws the "abort" and "error" event. you can check this answer for details

Solution 3:[3]

For later versions of express (i.e. express@^4.x) where body-parser is deprecated, delete, remove or comment out any app.use(express.json()) in your entry .js or .ts file.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jerry Lee
Solution 2 Community
Solution 3 Memphis