Rails development server not logging backtrace on 500 errors
Asked Answered
F

3

7

I recently updated my application to Rails 7.1 and the development server seems to have stopped logging error backtraces.

Example of the logs from a broken page:

Started GET "/coffees-subscription-choices" for ::1 at 2023-12-06 16:07:08 -0600
  ActiveRecord::SchemaMigration Load (0.8ms)  SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
Processing by GreatCoffeesController#index as HTML
  Rendering layout layouts/about.html.erb
  Rendering great_coffees/index.html.erb within layouts/about
  Rendered great_coffees/index.html.erb within layouts/about (Duration: 31.9ms | Allocations: 7867)
  Rendered layout layouts/about.html.erb (Duration: 32.1ms | Allocations: 8006)
Completed 500 Internal Server Error in 38ms (ActiveRecord: 12.5ms | Allocations: 11601)

No error message or backtrace.

I searched around a bit and applied these changes to config/initializers/new_framework_defaults_7_1.rb, but to no effect :/

Rails.application.config.action_dispatch.show_exceptions = :all
Rails.application.config.action_dispatch.debug_exception_log_level = :error

Anyone know what I might be missing? Rails 7.0 logged the backtrace for errors as expected.

Fourchette answered 6/12, 2023 at 22:33 Comment(5)
Just in case: the exceptions will be logged AFTER the Completed 500 ... line. You're only showing up to that line, so just putting this here on the off chance you're not thinking to look beyond that in your log setup. Are you seeing the development exception page in your browser? Or just the 500.html page?Coniferous
I'm not seeing the development exception page, it's showing the production exception page. And yeah, that's just the end of the log, there is nothing after Completed 500..Fourchette
Hmm, you sure Rails.env == "development"?Coniferous
Yeah, I've double checked the environment and it's development :/Fourchette
See you got it sorted, well done.Coniferous
F
9

Thanks to the suggestions from Pascal, I was able to nail this down to outdated versions of rollbar and web-console.

Updating these 2 gems got my error reports in development back to expected!

Using web-console 4.2.1 (was 3.7.0)
Using rollbar 3.4.2 (was 3.3.1)
Fourchette answered 14/12, 2023 at 1:2 Comment(2)
Thanks for putting me on the right track. Updating to the latest version of the Honeybadger gem fixed this problem.Limnology
Wauw I was searching for a solution for about a week. Rollbar update did the trick! Thank you very muchZurkow
G
9

We had the same problem and it happened that we used an old version of a gem (sentry-raven 3.1.2) that patched the DebugExceptions middleware. Because its render_exception method signature changed with Rails 7.1, the patch itself caused an exception. Both the original and the additional exception are then not shown anywhere.

The solution for us was to patch the outdated gem, because we are not able to upgrade there.

Guaiacol answered 12/12, 2023 at 9:41 Comment(6)
Ah, interesting. I wonder if Rollbar is doing the same thing, I'll take a look, thanks!Fourchette
Tried upgrading Rollbar to the latest version and also removing it completely. Neither seemed to make a difference unfortunately hmmm...Fourchette
Okay! Looks like I had to upgrade both rollbar and web-console and now it's working as expected. Thanks for putting me on the right track!Fourchette
THANK YOU. I am sure other devs will hit this issue when upgrading to Rails 7, and if they're like me, they'll assume the bug is somewhere else. This was a lifesaver!Celka
Wow, this saved me from pulling out the rest of my hair.Epileptic
Could you show us this Patch on sentry-raven?Grapple
F
9

Thanks to the suggestions from Pascal, I was able to nail this down to outdated versions of rollbar and web-console.

Updating these 2 gems got my error reports in development back to expected!

Using web-console 4.2.1 (was 3.7.0)
Using rollbar 3.4.2 (was 3.3.1)
Fourchette answered 14/12, 2023 at 1:2 Comment(2)
Thanks for putting me on the right track. Updating to the latest version of the Honeybadger gem fixed this problem.Limnology
Wauw I was searching for a solution for about a week. Rollbar update did the trick! Thank you very muchZurkow
C
1

For us, the culprit was the honeybadger gem; for some reason we had it pinned in our Gemfile; you need at least version 5.1.0 as per the changelog

Cavalier answered 15/6 at 13:3 Comment(1)
Good to know this too.Gorky

© 2022 - 2024 — McMap. All rights reserved.