Uploading file Angular.js FormData

I'm uploading a File with Angular to my Node server. Sometimes the image is not uploaded and I get req.files "undefined" in the server side and I can not figure it out why. I think it has not to do with the weight of the image: the image that is uploaded is around 48KB and the one that isn't 16KB. I attach two snapshot to show the difference in timing (http post) between the one that works and the other (network tab of Chrome developer tool). I can see that the "times" ("blocking", "sending") are not overlapping themselves in the one that is failing. Maybe is that the problem... but I'm not sure about how to fix it.

Timing in the post of the one that is not uploaded

enter image description here

I got it.

I was using express.multipart in the server side with defer option "express.multipart({defer: true})"

Because of that, sometimes the execution reached the code where I manage the post request to get the image with "req.files.file" before form's "end" event in express.multipart module is fired where the module sets req.files:

form.on('end', function(){ if (done) return; try { req.body = qs.parse(data); **req.files = qs.parse(files);** if (!options.defer) next(); } catch (err) { form.emit('error', err); } });

So sometimes req.files.file = undefined, simply because is not set yet...

Getting rid of {defer: true} option solves my problem. Nothing to do with one or another image.

Here you are the doc of "defers" option in express.multipart module:

"defers processing and exposes the Formidable form object as req.form. * next() is called without waiting for the form's "end" event. * This option is useful if you need to bind to the "progress" event, for example."