formidable: formidable parse callback not be called and no error

Hi, I have problem when I use formidable parse function. In my project, I use httpsys (not build-in http module) to create server (for port sharing), and then I send a post request with multipart form data(including string and zip file). Then I want to use formidable to parse request body. But parse function callback does not be called. There is no error. I do not use Express application, but I use Express Router to route my requests. I already use error handler to catch error, but it never be called (form.on(‘error’, function(err) { console.log(err); })😉. Anyone has same problem? Please help me out, thanks in advance.

 // main.js
    var express = require('express');
    var router = express.Router();
    router.use(function (req, res, next) {
    for (var i in req.headers) {
    req.headers[i] = querystring.unescape(req.headers[i]);
    req.headers[i] = req.headers[i].replace(/\+/g, "");
    }
    next();
   });
//router.use(bodyParser());
router.post('/TestServer/' + 'TestRequest', function(req, res) {
testRequestHandler.execute(req, res);
});
var server = require('httpsys').http().createServer(router);
var port = '80'; // or other port
var listeningPort = 'http://localhost:' + port + '/TestServer/';
server.listen(listeningPort );
   // In testRequestHandler
  var execute = function(req, res) {
    var form = new Formidable.IncomingForm();
    form.uploadDir = uploadDir.getPath();
    form.encoding = Constants.ENCODING_UTF8;
    form.on('file', function(name, file) {console.log('file='+file);});
    form.on('error', function(err) { console.log(err); }); // never be called
    form.on('aborted', function() { console.log('Aborted'); });
    form.parse(req, function(err, fields, files) {
        //todo test code
        console.log( "parse finished" );
    });
 }

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 9
  • Comments: 24 (9 by maintainers)

Most upvoted comments

@xarguments , thanks for your help, yes it working, but the problem was on the other part, i mean in a firewall configuration not related to the node-formidable.

@leading00, @AhmadMurtaza1, @tuannguyen192, thanks for reporting. I am trying to identify the root cause, and would like to receive your help in order to help you 😃

  1. Does it happen when you remove all other event handlers except the “parse” handler?
  2. Can you make sure that the request is received on the server-side?
  3. Do you use “httpsys” ? (please answer @tunnckoCore’s question).
  4. @AhmadMurtaza1, @tuannguyen19 (and others) could you please provide the code you used? I guess it has some differences.

Thanks.

@hatim-heffoudhi, have you checked maxFileSize option?

Hello, i receive the same error, but for me is when i upload image > 20mb

Nope. Do you use that httpsys module too?

Did you find the solution? I have same error!!!