Rails App On Heroku - Status Error 500 => Blank White Image

I have a Rails application on a Heroku staging server and everything went well except the error pages are not working. Every time I get a "status: 500" error, it results in a blank white page, not a 500.html static error page.

I have a 500.html static page in my_app / public folder and I can access it in heroku if I try to do it directly through myapp.herokuapp.com/500. Then it will be displayed. But if I get a real "status: 500" error in the program, it won't display the 500.html page ... rather, it displays a blank white page.

To create an error, I tried to navigate to a non-existent page. The logs indicate that there was a "status: 500" error, but again, a white page. Here is some of the output from the logs:

heroku[router]: at=info method=GET path="/fakepage" host=myapp.herokuapp.com request_id=20825-b474-4e-37f-c52486140 fwd="67.xxx.xxx.x" dyno=web.1 connect=1ms service=108ms status=500 bytes=949
Started GET "/fakepage" for xx.xxx.xxx.x at 2014-08-24 03:50:31 +0000
app[web.1]: ** [Raven] User excluded error: #<ActionController::RoutingError: No route matches [GET] "/fakepage">

      

In config / environment / staging.rb , I have the following:

config.consider_all_requests_local = false
config.serve_static_assets = true  #after the default of false didn't work

      

It seems like it shouldn't be one of those "hard problems" ... and not finding any previous posts or articles that are directly related to my question makes me think it must be something amiss on my part ... I am currently running Ruby 2.0.0p451 and Rails 4.1.1. I have a Sentry setup via heroku for error control. Let me know if there is any other useful information I could provide.

EDIT I should mention that my Gemfile looks like this:

  source 'https://rubygems.org'
  ruby '2.0.0'
  gem 'rails' #, '4.1.1'

  gem 'bcrypt'
  gem 'bootstrap_form'
  gem 'bootstrap-sass'
  gem 'carrierwave'                 
  gem 'coffee-rails'
  gem 'dropzonejs-rails'
  gem 'email_validator'             
  gem 'fog'                         
  gem 'geocoder'
  gem 'haml-rails'
  gem 'jquery-rails'
  gem 'jquery-turbolinks'
  gem 'jquery-ui-rails'
  gem 'mini_magick'                 
  gem 'paratrooper'                
  gem 'sass-rails'
  gem 'sidekiq'                     
  gem 'sinatra', require: nil       
  gem 'turbolinks'
  gem 'uglifier'
  gem 'unicorn'

  group :production, :staging do
    gem 'pg'
    gem 'rails_12factor'
    gem 'sentry-raven'
  end

      

That is, I have the "rails_12factor" gem in the correct group for both staging and production environments, as mentioned in a similar question regarding serving static assets in heroku with Rails4 ... essentially that would be an error page. I have an application setup to run multiple processes through Unicorn, and Unicorn is temporarily configured to handle Sidekiq processes internally while the application is in testing (to avoid a second speaker). Redis also works.

<strong> config / environment / staging.rb

Rails.application.configure do
  config.cache_classes = true
  config.eager_load    = true
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true

  config.serve_static_assets  = true
  config.assets.js_compressor = :uglifier
  config.assets.compress = true
  config.assets.compile  = true #WAS FALSE
  config.assets.digest   = true
  config.assets.version  = '1.0'

  config.action_mailer.default_url_options = { host: "..." }
  config.action_mailer.delivery_method = :smtp
  ActionMailer::Base.smtp_settings = {
    :port           => ENV['MAILGUN_SMTP_PORT'    ],
    :address        => ENV['MAILGUN_SMTP_SERVER'  ],
    :user_name      => ENV['MAILGUN_SMTP_LOGIN'   ],
    :password       => ENV['MAILGUN_SMTP_PASSWORD'],
    :domain         => '...',
    :authentication => :plain }

  config.log_level = :info #see everything in the log
  config.i18n.fallbacks = true
  config.log_formatter = ::Logger::Formatter.new
  config.action_dispatch.show_exceptions = false #per sentry-raven docs
  config.active_record.dump_schema_after_migration = false
  config.active_support.deprecation = :notify #send to registered listeners

      

+3


source to share


1 answer


Finally I got to the bottom of the problem. The takeaway is that Heroku will serve basic error pages when a status error (404, 500, etc.) occurs in a vanilla Rails app without any custom classes. Once I identified this, it helped guide the diagnosis.

Looking through the config / environment / staging.rb code I saw the LOC that the watchdog specified in their docs should be false:

config.action_dispatch.show_exceptions = false #per sentry-raven docs

      



After this value returned to true, the status error pages started working:

config.action_dispatch.show_exceptions = true #status error pages work again!

      

So, I may have been misunderstanding the sentry raven docs and mis-typing them into the Rails app config or whatever, but that's what the problem turned out to be. So, if you, your Rails-hosted Herles application do a great job and then run a white screen of death on any status error, this is one more thing to test your diagnostic attempts.

+3


source







All Articles