formidable icon indicating copy to clipboard operation
formidable copied to clipboard

Use formidable upload files, always get "Error Request Aborted"

Open EricCat opened this issue 12 years ago • 52 comments

  • I use Express(3.6.0) + formidable(latest) for upload files to S3.
  • When I submit post , then I always got Error Request Aborted.
  • incoming_form.js:
IncomingForm.prototype.parse = function(req, cb) {
.......
.......
.......
req
    .on('aborted', function() {
      self.emit('aborted');
      self._error(new Error('Request aborted'));
    })
.......
.......
.......
}
[Error: Request aborted]
child process: Request aborted
Error: Request aborted
at IncomingMessage.<anonymous>      
(/node_modules/formidable/lib/incoming_form.js:107:19)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
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:465:12)

I want to know why I got aborted and how to debug it.

EricCat avatar May 25 '14 23:05 EricCat

  • make formidable work nicely with body-parser
  • investigate what happens in case of abort What else do we need to do ?

GrosSacASac avatar Nov 28 '19 12:11 GrosSacASac

@lborgman @BrodaNoel @brodwen83 & others.

Please try npm install formidable@canary - preview of v2. The API is almost the same, check the docs or open new issue if there's some problem.

@GrosSacASac lets see what's the state with latest (formidable@canary) versions of both Formidable and Express. Then we can just document how to use it with Express, more correctly.

tunnckoCore avatar Jan 29 '20 06:01 tunnckoCore

koa2 meets the same problem, when using bodyParser with formidable. just remove it and I have sovled this proplem.

spade69 avatar Feb 25 '20 17:02 spade69

@spade69: just remove it

what you removed? Koa2 or Formidable@canary? Do you mean that the problem continue even with formidable@canary and latest koa2?

I'm going to publish v2 on 29th or 1st, so.. We may continue after that if it's still a problem.

tunnckoCore avatar Feb 29 '20 01:02 tunnckoCore

@spade69: just remove it

what you removed? Koa2 or Formidable@canary? Do you mean that the problem continue even with formidable@canary and latest koa2?

I'm going to publish v2 on 29th or 1st, so.. We may continue after that if it's still a problem.

sorry, i mean removing koa-body's bodyParser, i use [email protected] and latest koa2. Now everything works, thx

spade69 avatar Mar 04 '20 16:03 spade69

@spade69 Now everything works, thx

Cool! One last thing, do you mean with formidable@canary?

tunnckoCore avatar Mar 04 '20 17:03 tunnckoCore

I'm going to fix that in #594 and v2.

tunnckoCore avatar Mar 27 '20 13:03 tunnckoCore

@Amit-A Thx, that really helped

nickFelix avatar Apr 08 '20 15:04 nickFelix

May be we need not delete the bodyParser.json(). I add bodyParser.raw({ type: 'multipart/form-data', limit: '10mb' }) and solved.

const jsonParser = bodyParser.json({ limit: '10mb' });
const formParser = bodyParser.raw({ type: 'multipart/form-data', limit: '10mb' });

app.post(url, formParser, jsonParser, [controller.func...] )

chxlvwh avatar Oct 13 '20 02:10 chxlvwh

My problem was that after 70 to 90s request was aborted. I want to upload big files (2GB and more) to the api. But I was unable to upload bigger file then 2,8 GB on local host while testing.

I moved from koa2 to express (only because I understand express better). But still have the same error.

At the end I did try running tests in different node versions and I've succeed with version 15. Give it a try. I am using: "formidable": "1.2.2" and "express": "4.17.1", without bodyparser on upload route.

Ovec avatar Jan 20 '21 17:01 Ovec

  • Use recent version of Node to have nice default settings.
  • Use maxFileSize: 3 * 10 ** 9 option, to receive 3GB files and less
  • Do not use bodyParser and formidable, only use formidable
  • abort error can and will happen when a clients loses internet or navigates to another page
  • listen for error events to avoid abort error to crash the server, example:
const server = http.createServer((request, response) => {
    request.on(`error`, console.error.bind(console, `request error`));
    response.on(`error`, console.error.bind(console, `response error`));

GrosSacASac avatar Jan 20 '21 17:01 GrosSacASac

this works for me

 const form = new formidable.IncomingForm({maxFileSize:20 * 1024 * 1024});

RupamShaw avatar Jun 02 '21 08:06 RupamShaw