9

Essentially my problem is that a page loads fine and looks normal. After about 30 seconds it suddenly disappears.

Here's the server log before the error (as loading the page):

Started GET "/" for 127.0.0.1 at 2014-03-11 23:53:30 -0400
Processing by PagesController#home as HTML
  Rendered pages/home.html.erb within layouts/application (0.7ms)
  Rendered layouts/_head.erb (3.3ms)
  Rendered layouts/_header.erb (0.9ms)
  Rendered layouts/_footer.erb (0.2ms)
Completed 200 OK in 11ms (Views: 10.5ms)

Started GET "/assets/favicon.ico" for 127.0.0.1 at 2014-03-11 23:53:30 -0400

Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2014-03-11 23:53:30 -0400

Started GET "/assets/home.css?body=1" for 127.0.0.1 at 2014-03-11 23:53:30 -0400

Started GET "/assets/taylor.jpg" for 127.0.0.1 at 2014-03-11 23:53:30 -0400

Started GET "/assets/wide.jpg" for 127.0.0.1 at 2014-03-11 23:53:30 -0400

Started GET "/assets/enchanted_large.png" for 127.0.0.1 at 2014-03-11 23:53:30 -0400

Started GET "/assets/sad.jpg" for 127.0.0.1 at 2014-03-11 23:53:30 -0400

And then suddenly the image dissappears with the client side error (seen in Chrome's dev console):

Failed to load resource: net::ERR_CONTENT_LENGTH_MISMATCH
  http://localhost:3000/assets/taylor.jpg

And the only addition to the log is:

Started GET "/assets/favicon.ico" for 127.0.0.1 at 2014-03-11 23:54:00 -0400

During the 30 seconds of it looking good, chrome has a loading symbol where the favicon goes

My html is rather simple at this point:

<div class="home-images">
  <%= image_tag "taylor.jpg", class: "home-image" %>
  <%= image_tag "wide.jpg", class: "home-image hide" %>
  <%= image_tag "sad.jpg", class: "home-image hide" %>
</div>

I even took out my javascript completely. I tried removing turbolinks by itself too. It only happens to one image. And I have no idea why...

When I switched the html, it was the same image (taylor) that gave the error:

<div class="home-images">
  <%= image_tag "wide.jpg", class: "home-image" %>
  <%= image_tag "taylor.jpg", class: "home-image hide" %>
  <%= image_tag "sad.jpg", class: "home-image hide" %>
</div>

All my images are located in my app/assets/images folder

My header looks like this:

<head>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Enchanting Events and Design</title>
  <%= favicon_link_tag       "favicon.ico" %>
  <%= stylesheet_link_tag  "application" %>
  <%= javascript_include_tag  "application" %>
  <%= csrf_meta_tags %>
</head>
Tom Prats
  • 7,364
  • 9
  • 47
  • 77
  • what is the size of this http://localhost:3000/assets/taylor.jpg ? – Raghu Mar 12 '14 at 04:14
  • In a possibly, but maybe not unrelated note: finder is not responding currently (breaks when i enter the folder with the files). I'll get back to you ASAP – Tom Prats Mar 12 '14 at 04:20
  • @Raghu it's 350 by 290. Finder works again after restarting my computer, still get same error though – Tom Prats Mar 12 '14 at 14:06
  • which server are you running on local? webbrick? if yes then try using thin or mongrel and see if you are getting a different result – Raghu Mar 12 '14 at 17:50
  • I'm actually using thin – Tom Prats Mar 12 '14 at 20:09
  • possible duplicate of [Why code shows "Error 354 (net::ERR\_CONTENT\_LENGTH\_MISMATCH): The server unexpectedly closed the connection."](http://stackoverflow.com/questions/16357848/why-code-shows-error-354-neterr-content-length-mismatch-the-server-unexpec) – webknjaz -- Слава Україні Mar 28 '14 at 16:19
  • Did you ever solve this issue? – chopper Jun 20 '14 at 19:34
  • @chopper No, but it might've only happened locally. Are you having the problem too? I can look back into it – Tom Prats Jun 21 '14 at 18:50
  • Yes, Im having the same issue. It's only certain images andIn also only have this issue locally. Unfortunately running rake assets:clean as suggested below did not help. If you have any ideas what may be going on, that would be great. – chopper Jun 22 '14 at 01:04
  • Same issue here, really weird. I **solved** it partially by re-saving the image with GIMP. Are there any chance your image was saved with Illustrator or KolourPaint? – Francesco Belladonna Aug 23 '14 at 15:39
  • Mine came from the internet, but are you thinking a slightly corrupted file? – Tom Prats Aug 23 '14 at 20:35
  • @TMP: Yes, that's the only reason considering I didn't change code to actually "fix" it... – Francesco Belladonna Aug 25 '14 at 23:43

4 Answers4

27

Ran into the same issue when I edited my image size.

None of the above solutions worked for me, but rake tmp:clear did!

Neeharika Bhartiya
  • 1,601
  • 2
  • 14
  • 11
10

I had this issue when I replaced an image using the mv command. This left the timestamp untouched, so it broke the asset caching. A simple touch of the affected file fixed it.

Brian Williams
  • 116
  • 2
  • 3
2

Try "rake assets:clean" and rebuild your asset(if you need). I got working by this magic.

mogya
  • 93
  • 7
0

This may be a symptom of another problem with nginx. Please see this article:

Rails image disappears with error: Failed to load resource: net::ERR_CONTENT_LENGTH_MISMATCH

I saw the same issue as you, and it turned out to be an nginx permission issue with the underlying cache directory which also caused the problem to be somewhat intermittent.

Community
  • 1
  • 1
James V
  • 103
  • 2
  • 9