Skip to content
This repository has been archived by the owner on May 15, 2020. It is now read-only.

EOFError (bad content body) when uploading a file #125

Closed
skeevis opened this issue Apr 29, 2011 · 109 comments
Closed

EOFError (bad content body) when uploading a file #125

skeevis opened this issue Apr 29, 2011 · 109 comments

Comments

@skeevis
Copy link

skeevis commented Apr 29, 2011

When using Paperclip to upload a file, the file upload instantly fails, logging "EOFError (bad content body):"

The exact same operation works with Webrick

@andrewcarpenter
Copy link

Seeing the same thing when handling file uploads manually without paperclip (under rails 3); webrick works fine.

@thetron
Copy link

thetron commented May 18, 2011

I was having this issue as well, using carrierwave. Using mongrel or webrick was fine. Upgrading to pow 3.1 seemed to take care of it for me.

@raid5
Copy link

raid5 commented May 20, 2011

Updated to Pow 3.1 also. I'm hoping this solves what was a seemingly random error for me. I was only getting this error maybe once every 20-30 uploads.

@benpickles
Copy link

also seeing this

@jrmehle
Copy link

jrmehle commented May 24, 2011

+1 for this bug.

I did a bit of digging and discovered the issue might be fixed if rack-mount were updated something higher than version 0.6.14 however Rails 3.0.7 specifies "~> 0.6.14" so it is not possible to use anything higher than that in a Gemfile.

http://stackoverflow.com/questions/5785364/how-do-i-update-rack-when-using-rails-3-bundler-wont-let-me

@jerrod
Copy link

jerrod commented Jun 3, 2011

I get this on every upload regardless of file handling lib (carrierwave/paperclip/manual) with pow 0.3.1 and rack-mount 0.6.14

@jpsilvashy
Copy link

I'm receiving the same problem as well pow 0.3.1, rack-mount 0.8.1, carrierwave 0.5.4

@itschn
Copy link

itschn commented Jun 7, 2011

me too pow 0.3.1, rack-mount 0.8.1, paperclip

@jpsilvashy
Copy link

I know its not a real solution, but I just opted for uploading to S3 instead of local storage.

@winfred
Copy link

winfred commented Jun 9, 2011

I encountered the same issue with paperclip but realized I had to provide a content_type validation.

After looking at the request from the dev tools in browser, I realized it was only accepting image content types, which was not what I was hoping to upload. (For some reason this is the default for paperclip.)
adding this to my model worked just fine: (all the content types are for browser naming variations)

has_attached_file :audio
validates_attachment_content_type :audio, :content_type => ['audio/mp3', 'application/mp3', 'application/x-mp3', 'audio/mpeg', 'audio/mp3','audio/mpg']

@rmoriz
Copy link

rmoriz commented Jul 1, 2011

I run into this bug with a Rails 3.0.9 app and a simple upload field (no paperclip, carrierwave etc plugin) with pow 0.3.1

@christoph-buente
Copy link

Had the same issue with 0.3.0. Upgrading to 0.3.1 didn't solve the problem. It made it even worse, cause pow stopped working completely.

@rodrigoalvesvieira
Copy link

I just had this very error.

@mikepack
Copy link

mikepack commented Jul 8, 2011

+1 Same problem for me

@maletor
Copy link

maletor commented Jul 20, 2011

+1

2 similar comments
@mitio
Copy link

mitio commented Jul 21, 2011

+1

@camwest
Copy link

camwest commented Jul 26, 2011

+1

@gabekessler
Copy link

I was getting this error with paperclip. Files at 5mb gave the error. Same files resized down to under 1mb uploaded successfully. I did not test various other sizes to see if there was a tipping point.

@mscottford
Copy link

+1

4 similar comments
@awd
Copy link

awd commented Jul 28, 2011

+1

@vrybas
Copy link

vrybas commented Jul 31, 2011

+1

@wout
Copy link

wout commented Aug 1, 2011

+1

@alopes
Copy link

alopes commented Aug 11, 2011

+1

@gdeest
Copy link

gdeest commented Aug 22, 2011

Saw this problem too. Works in WebRick. Works in Passenger in production. Works from time to time with Pow, most of the time fails with this very same error.

If I have some time (a very limited resource !) I'll try to make a contrived example that exhibits this problem. But, due to the elusive nature of the problem, I fear it won't show up on the developers' machine...

@taras-yorku
Copy link

+1

@chrismccord
Copy link

I too am seeing this on 0.3.2

@josephers
Copy link

Happens to me every time I try to upload a file through Paperclip. I'm trying to upload 2.5MB files. Works in WEBrick.

@diddeb
Copy link

diddeb commented Sep 3, 2011

+1

@josephers
Copy link

This is not related to the X-Sendfile bug, is it?

@jrmehle
Copy link

jrmehle commented Sep 3, 2011

@josephers - It's not related to the X-Sendfile bug. This is bugged in Rails 3.0 too.

@theodorton
Copy link

+1

Fails in Rails with Pow 0.4.1 using a <input type="file" multiple /> having files of total file size above 16MB. Didn't find anything in the configuration doc that specified I could increase the maximum upload size. Works perfectly when the total file size is below 16MB.

The request goes through, but all the submitted parameters are stripped and running params in a debug console shows only :action and :controller are left.

If I use thin there are no problems.

@tylerhunt
Copy link

+1

Seeing the same result as @theodorton.

@marshmallowcreme
Copy link

+1

@mreinsch
Copy link

mreinsch commented Sep 9, 2013

+1 - Rails 3.2.13, Rack 1.4.5, Pow 0.4.1

I actually only got an "obfuscated" version of the error:

TypeError - can't convert nil into Hash:
  rack (1.4.5) lib/rack/request.rb:221:in `merge'
  rack (1.4.5) lib/rack/request.rb:221:in `params'

I then spend quite some time digging into rack to finally figure out that it's throwing a "bad content body" in rack-1.4.5/lib/rack/multipart/parser.rb:130.

Switched to unicorn and all seems fine now.

@atipugin
Copy link

+1

1 similar comment
@Phantoms
Copy link

+1

@speedmax
Copy link

No problem

On 17/10/2013, at 9:22 PM, Andrei Filimonov notifications@github.com wrote:

+1


Reply to this email directly or view it on GitHub.

@sookcha
Copy link

sookcha commented Nov 19, 2013

+1

2 similar comments
@alexbartling
Copy link

+1

@nhoffmann
Copy link

+1

@Undistraction
Copy link

+1

Definitely linked to file size.

@xiaods
Copy link

xiaods commented Dec 8, 2013

+1 Definitely limited to file size.

@walter
Copy link

walter commented Jan 3, 2014

+1

Just experienced this as well. 15Mb file causes overall form to fails with "WARNING: Can't verify CSRF token authenticity" message.

Mac OS X 10.8.5, Safari 6.1, Carrierwave 0.9.0, Rails 3.2.16.

I confirmed that a 77Kb file works fine.

I also confirmed that the problem doesn't occur with webrick with the 15Mb file.

@alexsiri7
Copy link

+1

We're having the same problem, BUT: This happens after uploading a file, then right away uploading a second file. If we only try to upload one file (or if we wait long enough) everything works correctly. The file size is of 700kb.

So possibly not an issue on file size, but on the amount of memory used to process the files.

@brandonaaskov
Copy link

+1 (file size related as well)

@firedev
Copy link

firedev commented Feb 4, 2014

Is it Pow-specific? Or should I be careful pushing the same code to production as well?

@anny-goerl
Copy link

I had this error always when using pow. no problems, with thin or webrick or in production. That's why I don't use Pow anymore.

@Emerson
Copy link

Emerson commented Feb 13, 2014

Having this problem as well!

@elsurudo
Copy link

Same here. Pow + Carrierwave

@madrobby
Copy link

madrobby commented Mar 3, 2014

Same issue here, pow 0.4.1, Rails 2.3, REE 1.8.7. Small files work, larger file (this one has ~10MB).

/!\ FAILSAFE /!\  Mon Mar 03 11:47:12 -0500 2014
  Status: 500 Internal Server Error
  bad content body
    /Users/thomasfuchs/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/rack-1.1.6/lib/rack/utils.rb:530:in `parse_multipart'
    /Users/thomasfuchs/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/rack-1.1.6/lib/rack/request.rb:268:in `parse_multipart'
    /Users/thomasfuchs/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/rack-1.1.6/lib/rack/request.rb:146:in `POST'
    /Users/thomasfuchs/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/rack-1.1.6/lib/rack/methodoverride.rb:15:in `call'

@xiaods
Copy link

xiaods commented Mar 4, 2014

Hi All, If we only report bug, not identify the root reason, we will can't get it resolved. anyone can help us and give some hints.

@tomafro
Copy link
Contributor

tomafro commented Mar 17, 2014

I can consistently reproduce this (or at least related) problems using pow with both rails and sinatra. A simple app showing this is here: https://github.com/tomafro/pow-large-upload-failure. It works using both rack and nack directly, but throws a NoMethodError caused by a 'missing' file.

@jdelStrother
Copy link

For what it's worth, I put a bunch of debug logs into the Nack::Server code (which is where the Ruby process receives data from the nodejs HTTP server).

read_nonblock (https://github.com/josh/nack/blob/master/lib/nack/server.rb#L107) receives a blob of data looking like <HEADER_SIZE>:<HTTP_HEADER_AS_JSON>,<BODY_SIZE>:<HTTP_BODY>. The sizes and the header all look sane. However, the http body within that blob is not the start of the request body - it's taken from a ways into it. The size of the chunk that's missing appears to be fairly random, but I've seen values from 92kb - 800kb.

Weirdly, the actual start of the request body then appears mangled into the buffer that Nack::Server is piecing together. However the tail of the request body seems to reliably come at the end of the buffer. It kind of seems like the body chunks are getting received out of order.

@tomafro
Copy link
Contributor

tomafro commented Mar 17, 2014

@jdelStrother That's really useful, thanks. Looks like we'll need to look a little higher up the chain to see what's mangling the data.

@tomafro
Copy link
Contributor

tomafro commented Apr 2, 2014

d3f4836 should fix this data mangling bug

@jdelStrother
Copy link

Outstanding, thanks. I just transferred a 50MB file with no problems, which I've never been able to do before on Pow.

@sandstrom
Copy link

This is awesome!

I understand that individual issues can't dictate new released, but I hope you can mint a new version soon :)

@tomafro
Copy link
Contributor

tomafro commented Apr 4, 2014

@sandstrom Freshly baked 0.4.3 release now available

@sandstrom
Copy link

@tomafro Awesome, thanks! ⛵

@Undistraction
Copy link

Thanks for fixing this one.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests