4

The Miniprofiler gem for rails is very handy. (github, railscast)

However, I am getting a lot of 404 errors in my application:

In the chrome console, tab network:

Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost.mysite.com/mini-profiler-resources/results

This page returns the following response: Request not found: - user 127.0.0.1

On every page, I have 9 of those requests. (so it clogs my logs, and it's annoying). And 9 more show up every time I trigger an ajax request.

It seems that mini profiler is trying to evaluate the time of a request that doesn't happen... How can I troubleshoot this situation ?


Update: I've noticed that this gem also make the loading of images very slow. The images have a pending time (in the network tab) that ranges from 1 to 20 seconds, then they are loaded. Visually, you see images popping one after another very slowly.

I've tried to fiddle with the development.rb config settings (config.consider_all_requests_local, config.assets.debug, config.cache_classes, and config.assets.compress) without success. I have also tried to change my domain (dev.mysite.com with entry in /etc/hosts, localhost, 127.0.0.1 and localhost:3000). In every case, the gem makes image loading very slow. If I remove the gem, it's fast again.

Update 2: Sometimes (and I still don't know why), images load fast even with the gem after restarting the server. So the situation is like this:

  • Miniprofiler included in gemfile => 404 errors, images load slowly 90% of the time
  • Miniprofile not included in gemfile => No 404 errors, images load normally
Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
Benjamin Crouzier
  • 40,265
  • 44
  • 171
  • 236

2 Answers2

3

rm -fr tmp/miniprofiler worked for me. found it here https://github.com/MiniProfiler/rack-mini-profiler/issues/71

sprimon
  • 146
  • 1
  • 5
1

I looks like it was a problem with rights:

I was starting the server with rvmsudo rails server -p 80, and that caused miniprofiler to put files in tmp/miniprofiler as root.

Before (with rvmsudo rails server -p 80):

$> ls -la tmp/miniprofiler/mp_timers
-rw-r--r--  1 root  root  1427 Aug 31 17:18 tmp/miniprofiler/mp_timers_14p99y...
...

=> 404 errors and slow images

After: (with rails s)

$> ls -la tmp/miniprofiler/mp_timers
-rw-r--r--  1 pinouchon  staff  1427 Aug 31 17:18 tmp/miniprofiler/mp_timers_14p99y...
...

=> no 404 errors and images load normally.


The only problem with that is that I can't start my server on port 80: it says

$> rails s -p 80
Exiting
/Users/sharewizz/.rvm/gems/ruby-1.9.3-p392@sharewizz/gems/eventmachine-1.0.3/lib/eventmachine.rb:526:in `start_tcp_server': no acceptor (port is in use or requires root privileges) (RuntimeError)
    from /Users/sharewizz/.rvm/gems/ruby-1.9.3-p392@sharewizz/gems/eventmachine-1.0.3/lib/eventmachine.rb:526:in `start_server`

Because only root can start application on port less than 1024...

Benjamin Crouzier
  • 40,265
  • 44
  • 171
  • 236
  • 1
    Thanks for posting this. Came across the same error except I don't know why my files had an issue as I didn't start the server as root. Anyway, I just did a "sudo rm -r tmp/miniprofiler/*" seemed to sort it out. – Tyrone Wilson Nov 29 '13 at 09:32