Sails: Empty upload fields again in 0.5.5

Created on 22 Feb 2015  路  8Comments  路  Source: balderdashy/sails

I have the same issue as in #23 .

my code: https://gist.github.com/moglash/30723a81d10c873f21cb
error:

Error: EMAXBUFFER: An Upstream (`NOOP_file`) timed out before it was plugged into a receiver. It was still unused after waiting 4500ms. You can configure this timeout by changing the `maxTimeToBuffer` option.
    at null.<anonymous> (.../node_modules/sails/node_modules/skipper/standalone/Upstream/Upstream.js:86:15)
    at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)
22 Feb 15:14:24 - [nodemon] app crashed - waiting for file changes before starting...

Most helpful comment

FYI @handonam and I just spent an hour tracking this down at a hack night... @antocorso check to make sure you're only calling req.file('blah') once, and calling upload on the object returned. It turns out that at least in the empty case, every time you call req.file('blah') it returns a new object that needs to have upload set on it, so if you do something like

if(req.file('blah')._files.length) {
   // do something 
} else {
  // clear the buffer
  req.file('blah').upload(function() {});
}

This results in creating the object twice, and only the second would have the upload set. Instead do something like

var reqFile = req.file('blah');
if(reqFile._files.length) {
  // do something
} else {
  // clear the buffer
  reqFile.upload(function() {});
}

All 8 comments

I am also facing this error, can you suggest a way to avoid a server crash is form type is not multipart.

I have the same problem.
I check if an optional file was uploaded, if not I get an error even if I manage the upload (using upload callback).
Of course I have the last version of sails and skipper.
This is a very serious problem!!!

FYI @handonam and I just spent an hour tracking this down at a hack night... @antocorso check to make sure you're only calling req.file('blah') once, and calling upload on the object returned. It turns out that at least in the empty case, every time you call req.file('blah') it returns a new object that needs to have upload set on it, so if you do something like

if(req.file('blah')._files.length) {
   // do something 
} else {
  // clear the buffer
  req.file('blah').upload(function() {});
}

This results in creating the object twice, and only the second would have the upload set. Instead do something like

var reqFile = req.file('blah');
if(reqFile._files.length) {
  // do something
} else {
  // clear the buffer
  reqFile.upload(function() {});
}

:+1: thanks @kball ! Just to note, the callback in .upload() was important for it to work.

Thanks for posting, @barczaG. I'm a repo bot-- nice to meet you!

It has been 60 days since there have been any updates or new comments on this page. If this issue has been resolved, feel free to disregard the rest of this message. On the other hand, if you are still waiting on a patch, please:

  • review our contribution guide to make sure this submission meets our criteria (only _verified bugs_ with documented features, please; no questions, commentary, or bug reports about undocumented features or unofficial plugins)
  • create a new issue with the latest information, including updated version details with error messages, failing tests, and a link back to the original issue. This allows GitHub to automatically create a back-reference for future visitors arriving from search engines.

Thanks so much for your help!

Thanks it still working on Sails v0.12.3

Thanks @kball is working like a charm.

It doesn't work in Sails v1

Was this page helpful?
0 / 5 - 0 ratings